From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E84LpuGS; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 292AD5A0274 for ; Thu, 19 Dec 2024 20:48:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734637687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7VNoTPsld9Qpx/TR33eAnRQjw8DgqIypbcsuhKDem00=; b=E84LpuGSp2UiW1TOpKP+8NROrkF8zzeThePxnN86J1MmOASkugKQwhAkFTq4da62llxoWN QCnFmhjZG34xJkGdAfnIyq3GKoXx6+eiU75QR4HZKZPaNCvoTe0s0Y+F9NytA+40J2EDO+ OkeupjuqLqCMikIknai8DcTW2nHuCXo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-fZKa2nM5Pv2rjrmKZBpbVA-1; Thu, 19 Dec 2024 14:48:05 -0500 X-MC-Unique: fZKa2nM5Pv2rjrmKZBpbVA-1 X-Mimecast-MFC-AGG-ID: fZKa2nM5Pv2rjrmKZBpbVA Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-385fdff9db5so513424f8f.0 for ; Thu, 19 Dec 2024 11:48:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734637683; x=1735242483; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7VNoTPsld9Qpx/TR33eAnRQjw8DgqIypbcsuhKDem00=; b=J/FqaU0Dfy+am+YLqqM365KvyHDho+FuunuPm2tcRZxiRx3iaBckIKXkz3rKvdlVsq Czsd2czKm2clORK1v0NVoG5iLT9wtDRxeqHrPKHZQYzY/FM4rMehaSk1u5ZB0GiQ/zC9 kl6FwlkwLLdwV2WU0nNJFsHLAAPK2P6yIuDl0nZV49VqQt33rZn3GoGU0zVJyHik/aS5 YY0J4MVQa5WUcA8RQQfdMs3D+Q3DmC+oTv4jzZXgB3bWeZu4BPd/gUTYyRpZTbcQiM82 P54GKceNIvbaxV8nZRYVms/7AjtQijlin3a/CJd1WJZP5CVx6R2Mb6DIyrvFdrCySGIm LBXg== X-Gm-Message-State: AOJu0YyvMSUN8JZzUznNEjtd3O4GIVYzDtj+pfebKikb/6jQaFKT8Tij QX4VcHMQ/7qIQxQxyjcFQS5Hqc+Nl6bkcwD3bPTWMpNRVblBT0CwEryzMQ8jjoxA+yBv+yGjR2R RznoD17xSl7FJ8xvvyw16IsR2xxlGDXHcLaZmfYShfDtzcS36V3p4pE6trqasN8CIuNFvHdCMMa EjRfGmkSpXTAMjUH7LGVDbuGMtoKcUO41P X-Gm-Gg: ASbGncs6y4+DxcMwphKGp0KQDIXccUS44Qr8O594dyBXPFxKR+5AMa9CDxgozmMwSOC 2pG6AoX7eMVS6CZnDRlv5OMPtlm/h7AtE+WdSJT1BSbQG8doizYeFnvS5N/ePzjhqyhuuUdJQH2 GXrNvl/aG99LC2vc82SPUpjmitI4y/qV0h0Bpl9YFZ+VBOmi0iC9VGBxc0Ah9Jo3S5/vjyIPsiP 5HdfUBBrUZqtCHhrZamqeSdWWs4CiLmHLOdhs5wnM67QsiL6lx7P7SXiyluyuPkQJOOsJCWtVkD WOxDckpgjg== X-Received: by 2002:a05:6000:4704:b0:386:2bac:139 with SMTP id ffacd0b85a97d-38a22408b98mr223801f8f.54.1734637682878; Thu, 19 Dec 2024 11:48:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IErT+ISNT11ZNQ7bSpQ7Chb3BEXEBYlCgb+tx7gzRfGCDc6DECG1gkFWuiACHD035nucc0H/w== X-Received: by 2002:a05:6000:4704:b0:386:2bac:139 with SMTP id ffacd0b85a97d-38a22408b98mr223785f8f.54.1734637682445; Thu, 19 Dec 2024 11:48:02 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c833899sm2262680f8f.42.2024.12.19.11.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 11:48:01 -0800 (PST) Date: Thu, 19 Dec 2024 20:47:59 +0100 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH 8/9] vhost-user: add VHOST_USER_SET_DEVICE_STATE_FD command Message-ID: <20241219204759.65bc5353@elisabeth> In-Reply-To: <20241219111400.2352110-9-lvivier@redhat.com> References: <20241219111400.2352110-1-lvivier@redhat.com> <20241219111400.2352110-9-lvivier@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PZ0G9y1d_TuB6aviRQ_g3NBcxZjJJkZdwsn60QvSx-c_1734637684 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: HXSQLVRUS5NBR7GMIQQ52SJM44A6QE45 X-Message-ID-Hash: HXSQLVRUS5NBR7GMIQQ52SJM44A6QE45 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 19 Dec 2024 12:13:59 +0100 Laurent Vivier wrote: > +/** > + * vu_migrate() -- Send/receive passt insternal state to/from QEMU Magic! > + * @vdev: vhost-user device > + * @events: epoll events > + */ > +void vu_migrate(struct vu_dev *vdev, uint32_t events) > +{ > + int ret; > + > + /* TODO: collect/set passt internal state > + * and use vdev->device_state_fd to send/receive it > + */ > + debug("vu_migrate fd %d events %x", vdev->device_state_fd, events); > + if (events & EPOLLOUT) { I haven't really reviewed the series yet, but I have a preliminary question: how does the hypervisor tell us that we're writing too much? I guess we'll do a short write and we'll need to go back to EPOLLOUT? There's no minimum chunk size we can write, correct? > + debug("Saving backend state"); > + > + /* send some stuff */ > + ret = write(vdev->device_state_fd, "PASST", 6); > + /* value to be returned by VHOST_USER_CHECK_DEVICE_STATE */ > + vdev->device_state_result = ret == -1 ? -1 : 0; > + /* Closing the file descriptor signals the end of transfer */ > + epoll_ctl(vdev->context->epollfd, EPOLL_CTL_DEL, > + vdev->device_state_fd, NULL); > + close(vdev->device_state_fd); > + vdev->device_state_fd = -1; > + } else if (events & EPOLLIN) { ...and similarly here, I guess we'll get a short read? > + char buf[6]; > + > + debug("Loading backend state"); > + /* read some stuff */ > + ret = read(vdev->device_state_fd, buf, sizeof(buf)); > + /* value to be returned by VHOST_USER_CHECK_DEVICE_STATE */ > + if (ret != sizeof(buf)) { > + vdev->device_state_result = -1; > + } else { > + ret = strncmp(buf, "PASST", sizeof(buf)); > + vdev->device_state_result = ret == 0 ? 0 : -1; > + } > + } else if (events & EPOLLHUP) { > + debug("Closing migration channel"); > + > + /* The end of file signals the end of the transfer. */ > + epoll_ctl(vdev->context->epollfd, EPOLL_CTL_DEL, > + vdev->device_state_fd, NULL); > + close(vdev->device_state_fd); > + vdev->device_state_fd = -1; > + } > +} -- Stefano