From nobody Wed Jan 7 09:29:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1767003739; cv=none; d=zohomail.com; s=zohoarc; b=SUtTGkIsKjqcJUziSJEWnam9aqcw1Xkcf1SxJOe9v9pnfBS/7pD23pMkvblmq8v+sFdbJTNkvYr1eyQe+HJNz0SvFQInfgpYJuZRcmbPVfs2ncsZH3D8jR7xO+Y2O+8TEPXml+Y/Kd1s9TKb+1geb/k72gRkMhAAstrkG5ouVjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767003739; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZAd/Fxgvks8ojlWBXFbKSd9KMAVUVGhazsRwe+yiqKM=; b=GQC1a22WCccF48ZgVTTrF6M4Qy2Y7OGNm8nHSfu/DoyKdACtMoCEBnwRXgSbzrFwS1x95Z+038aOR5rSeCDXW6/uUj2RsCQ15PHsY8SrLAcCLUBbH2ZZzWEEMyaLb2H+b78fntoB9URK3YcBBEmLfrnQ1eMEKWK+L96ItVrfVL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767003739312900.1945343602082; Mon, 29 Dec 2025 02:22:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaANg-0000Rh-61; Mon, 29 Dec 2025 05:21:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaANe-0000R1-6K; Mon, 29 Dec 2025 05:21:38 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaANc-0005Kt-CZ; Mon, 29 Dec 2025 05:21:37 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 83D3DC0154; Mon, 29 Dec 2025 13:21:34 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:b4e::1:2a]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id HLeDGC1Ck0U0-KSSM3rgi; Mon, 29 Dec 2025 13:21:33 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1767003694; bh=ZAd/Fxgvks8ojlWBXFbKSd9KMAVUVGhazsRwe+yiqKM=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=yjZLNBs/3TdfWU3E7J/lzviCsR+GMrsoHkmhNJ3nirKhJCiW4EauPlZS6IZhilZFW fkBP1GqkXVuC8kVpN7FB5X8n57f6lv0l/NKb8c4gARSuJ/KUV3Y0Ah83w3ZN3+xtp7 sRy1ApHHZXs7cqOUczb+oij1HuFCdyT/7xDuv/Y0= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Zhenwei Pi , "Michael S. Tsirkin" , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com, Peter Xu , Fabiano Rosas , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "yc-core@yandex-team.ru" , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v4 1/5] vhost-user.rst: specify vhost-user back-end action on GET_VRING_BASE Date: Mon, 29 Dec 2025 15:21:05 +0500 Message-Id: <20251229102107.1291790-2-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> References: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1767003742374158500 Content-Type: text/plain; charset="utf-8" By default, we assume that server need to wait all inflight IO on GET_VRING_BASE. However, this fact is not recorded anywhere in the documentation. So, add this info in rst. Signed-off-by: Alexandr Moshkov --- docs/interop/vhost-user.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 2e50f2ddfa..02908b48fa 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1243,7 +1243,8 @@ Front-end message types =20 When and as long as all of a device's vrings are stopped, it is *suspended*, see :ref:`Suspended device state - `. + `. The back-end must complete all inflight I/O + requests for the specified vring before stopping it. =20 The request payload's *num* field is currently reserved and must be set to 0. --=20 2.34.1 From nobody Wed Jan 7 09:29:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1767003739; cv=none; d=zohomail.com; s=zohoarc; b=lDgKcXt7P6k7/ceAc4lm0E9hEk1SdnX2EZhXnJRaS9MzhwWuqoQ9Twi5wsRPvDlwWz0CjlefrmfqIkIMkouaXnwlKpCE4JzgkfNVWP2JY/AetgxUOd7/wSuEe1bFG4pSZ/smTK7KpxKu5YW83da+YTXavApq0owXhTcRFPrOLcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767003739; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0QTa5kigaZbjsqfFKaBCY/LC6aKCIF/YeBz7edCUmjU=; b=KjDioKUOJRU3qSBHeosY4jQHEGo32Z+LDKvloECN+w/mmifYySNPi0ZGeFWMigDuzv6KvTm5FApbOHSVnUnIB3dHs754cFdqUs4/ePZYLaCja81XXKZ8kYLQ2yuKOpD/i5kMaTcIHxz8q80xgfdrqx5/YA6ruL+cszGiKWpQCYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767003739388181.2692465578076; Mon, 29 Dec 2025 02:22:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaAO0-0000X8-DN; Mon, 29 Dec 2025 05:22:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaANu-0000WI-MY; Mon, 29 Dec 2025 05:21:54 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaANs-0005N2-9c; Mon, 29 Dec 2025 05:21:54 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 3C762C0153; Mon, 29 Dec 2025 13:21:50 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:b4e::1:2a]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id HLeDGC1Ck0U0-63Zs01aL; Mon, 29 Dec 2025 13:21:49 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1767003709; bh=0QTa5kigaZbjsqfFKaBCY/LC6aKCIF/YeBz7edCUmjU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=cfZT2mhQnoOIKVWU+mHfYsXAL2bZER2wAbZlBiiOrtZV5nL1/Z6drvN3Lr0JrgETZ Njs+IAPP781Gp1y76BuswkJllUmTvwZp9LLrjCVD5+3mDPqqqnj85es8WueMYtUNhG vMaM3nFB0/+g8jOROwHBiIz8a/O6hWJuZgDd4xcA= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Zhenwei Pi , "Michael S. Tsirkin" , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com, Peter Xu , Fabiano Rosas , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "yc-core@yandex-team.ru" , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v4 2/5] vhost-user: introduce should_drain on GET_VRING_BASE Date: Mon, 29 Dec 2025 15:21:07 +0500 Message-Id: <20251229102107.1291790-3-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> References: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1767003742375158500 Content-Type: text/plain; charset="utf-8" Now on GET_VRING_BASE QEMU can control whether to wait for in-flight requests to complete or not. It will be helpfull in future for in-flight requests migration in vhost-user devices. Signed-off-by: Alexandr Moshkov --- backends/cryptodev-vhost.c | 2 +- backends/vhost-user.c | 2 +- docs/interop/vhost-user.rst | 11 +++++++---- hw/block/vhost-user-blk.c | 3 ++- hw/net/vhost_net.c | 9 +++++---- hw/scsi/vhost-scsi-common.c | 2 +- hw/virtio/vdpa-dev.c | 2 +- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-scmi.c | 2 +- hw/virtio/vhost-vsock-common.c | 2 +- hw/virtio/vhost.c | 24 +++++++++++++++--------- include/hw/virtio/vhost.h | 7 +++++-- 13 files changed, 42 insertions(+), 28 deletions(-) diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index b4dafb4062..aaa4e6bfcb 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -109,7 +109,7 @@ static void cryptodev_vhost_stop_one(CryptoDevBackendVhost *crypto, VirtIODevice *dev) { - vhost_dev_stop(&crypto->dev, dev, false); + vhost_dev_stop(&crypto->dev, dev, false, true); vhost_dev_disable_notifiers(&crypto->dev, dev); } =20 diff --git a/backends/vhost-user.c b/backends/vhost-user.c index e65ba7b648..bb271c4d68 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -108,7 +108,7 @@ vhost_user_backend_stop(VhostUserBackend *b) return 0; } =20 - ret =3D vhost_dev_stop(&b->dev, b->vdev, true); + ret =3D vhost_dev_stop(&b->dev, b->vdev, true, true); =20 if (k->set_guest_notifiers && k->set_guest_notifiers(qbus->parent, b->dev.nvqs, false) < 0) { diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 02908b48fa..803d5c6b8f 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1243,11 +1243,14 @@ Front-end message types =20 When and as long as all of a device's vrings are stopped, it is *suspended*, see :ref:`Suspended device state - `. The back-end must complete all inflight I/O - requests for the specified vring before stopping it. + `. =20 - The request payload's *num* field is currently reserved and must be - set to 0. + The request payload's *num* field controls inflight I/O handling: + + * When *num* is set to 1, the back-end must complete all inflight I/O + requests for the specified vring before stopping it. + * When *num* is set to 0, the back-end may stop the vring immediately + without waiting for inflight I/O requests to complete. =20 ``VHOST_USER_SET_VRING_KICK`` :id: 12 diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a8fd90480a..56d55c18c8 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -227,6 +227,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); int ret; bool force_stop =3D false; + bool should_drain =3D true; =20 trace_vhost_user_blk_stop_in(vdev); =20 @@ -247,7 +248,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) migrate_local_vhost_user_blk()); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true); + vhost_dev_stop(&s->dev, vdev, true, should_drain); =20 if (k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false) < 0) { error_report("vhost guest notifier cleanup failed: %d", ret); diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index c4526974fb..4be966432e 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -384,7 +384,7 @@ fail: if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, true); fail_start: return r; } @@ -403,7 +403,7 @@ static void vhost_net_stop_one(struct vhost_net *net, if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, true); if (net->nc->info->stop) { net->nc->info->stop(net->nc); } @@ -636,7 +636,8 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetC= lientState *nc, vhost_virtqueue_stop(&net->dev, vdev, net->dev.vqs + idx, - net->dev.vq_index + idx); + net->dev.vq_index + idx, + true); } =20 int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, @@ -686,7 +687,7 @@ err_start: assert(ret >=3D 0); } =20 - vhost_dev_stop(&net->dev, vdev, false); + vhost_dev_stop(&net->dev, vdev, false, true); =20 return r; } diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index 43525ba46d..57b40301ed 100644 --- a/hw/scsi/vhost-scsi-common.c +++ b/hw/scsi/vhost-scsi-common.c @@ -108,7 +108,7 @@ int vhost_scsi_common_stop(VHostSCSICommon *vsc) VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); int ret =3D 0; =20 - ret =3D vhost_dev_stop(&vsc->dev, vdev, true); + ret =3D vhost_dev_stop(&vsc->dev, vdev, true, true); =20 if (k->set_guest_notifiers) { int r =3D k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, fals= e); diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index b6b4ee7d38..45bb8ca59b 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -301,7 +301,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev) return; } =20 - vhost_dev_stop(&s->dev, vdev, false); + vhost_dev_stop(&s->dev, vdev, false, true); =20 ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (ret < 0) { diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 0768231a88..8277d75ce9 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -77,7 +77,7 @@ static int vub_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true, true); =20 if (k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false) <= 0) { error_report("vhost guest notifier cleanup failed: %d", ret); diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 2a8eead90b..2b4b52de52 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -111,7 +111,7 @@ static int vuf_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true, true); =20 if (k->set_guest_notifiers(qbus->parent, fs->vhost_dev.nvqs, false) < = 0) { error_report("vhost guest notifier cleanup failed: %d", ret); diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 40e567c18a..580ffa0e2e 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -101,7 +101,7 @@ static int vu_scmi_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(vhost_dev, vdev, true); + ret =3D vhost_dev_stop(vhost_dev, vdev, true, true); =20 if (k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false) < 0) { error_report("vhost guest notifier cleanup failed: %d", ret); diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index c6c44d8989..a2c52c8914 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -106,7 +106,7 @@ int vhost_vsock_common_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true, true); =20 if (k->set_guest_notifiers(qbus->parent, vvc->vhost_dev.nvqs, false) <= 0) { error_report("vhost guest notifier cleanup failed: %d", ret); diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c46203eb9c..cb2e21bd75 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1426,11 +1426,13 @@ fail: static int do_vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx, bool force) + unsigned idx, bool force, + bool should_drain) { int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { .index =3D vhost_vq_index, + .num =3D should_drain, }; int r =3D 0; =20 @@ -1481,9 +1483,10 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx) + unsigned idx, + bool should_drain) { - return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false); + return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false, should_drain= ); } =20 static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev, @@ -2310,7 +2313,8 @@ fail_vq: vhost_virtqueue_stop(hdev, vdev, hdev->vqs + i, - hdev->vq_index + i); + hdev->vq_index + i, + true); } =20 fail_mem: @@ -2325,7 +2329,7 @@ fail_features: =20 /* Host notifiers must be enabled at this point. */ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, - bool vrings, bool force) + bool vrings, bool force, bool should_drain) { int i; int rc =3D 0; @@ -2361,7 +2365,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, = VirtIODevice *vdev, vdev, hdev->vqs + i, hdev->vq_index + i, - force); + force, + should_drain); } if (hdev->vhost_ops->vhost_reset_status) { hdev->vhost_ops->vhost_reset_status(hdev); @@ -2383,15 +2388,16 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, return rc; } =20 -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings, + bool should_drain) { - return do_vhost_dev_stop(hdev, vdev, vrings, false); + return do_vhost_dev_stop(hdev, vdev, vrings, false, should_drain); } =20 int vhost_dev_force_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) { - return do_vhost_dev_stop(hdev, vdev, vrings, true); + return do_vhost_dev_stop(hdev, vdev, vrings, true, false); } =20 int vhost_net_set_backend(struct vhost_dev *hdev, diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 13ca2c319f..94fb9a6654 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -235,6 +235,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * @hdev: common vhost_dev structure * @vdev: the VirtIODevice structure * @vrings: true to have vrings disabled in this call + * @should_drain: true for notice back-end to drain in-flight requests * * Stop the vhost device. After the device is stopped the notifiers * can be disabled (@vhost_dev_disable_notifiers) and the device can @@ -242,7 +243,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * * Return: 0 on success, !=3D 0 on error when stopping dev. */ -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings= ); +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, + bool vrings, bool should_drain); =20 /** * vhost_dev_force_stop() - force stop the vhost device @@ -400,7 +402,8 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint= 64_t iova, int write); int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, unsigned idx); int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, - struct vhost_virtqueue *vq, unsigned idx); + struct vhost_virtqueue *vq, unsigned idx, + bool should_drain); =20 void vhost_dev_reset_inflight(struct vhost_inflight *inflight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); --=20 2.34.1 From nobody Wed Jan 7 09:29:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1767003784; cv=none; d=zohomail.com; s=zohoarc; b=k8Nj4/y6X6LS9CD008wE4NAgnGx/Imw/pbSedade4FV3RZ1mmOYRtwK3HuqpOESAa56X+pQn5aTKfds7Uu9lXpyXq0OykYXDFZ+DJv7TZOi5Qj+dOqw/YE7FjJ9jy+PIT3ZUDQj0acC82wV/oFL98H0HhzWEfO0RJ40gR3l9X1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767003784; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BBaLzRPC1vSdvTfCEYutHaoyo6yavs9dofrXa1+5uLk=; b=Xgh8Zun/r/TD2b/mcPnwmQSIlokHMZ4RtDoQ6Y22u7RBkTRu7NiVK4oQqTGKlFkjAHKwRQYpM80JK6k02O4itdOKaeIKOJHqKSlwR+IAa8I3TVtCIrWmYLvmWrjDnH2uwYjTvDO+u0qDqBi4vx84w5zAb3YicVMesTnox1PJ2Jc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767003784634709.2455395316775; Mon, 29 Dec 2025 02:23:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaAOu-0001EX-KM; Mon, 29 Dec 2025 05:22:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOV-0000fo-VZ; Mon, 29 Dec 2025 05:22:37 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOT-0005RW-Bk; Mon, 29 Dec 2025 05:22:31 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 3BAA2C0161; Mon, 29 Dec 2025 13:22:27 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:b4e::1:2a]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id HLeDGC1Ck0U0-Q5LwhvEO; Mon, 29 Dec 2025 13:22:26 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1767003746; bh=BBaLzRPC1vSdvTfCEYutHaoyo6yavs9dofrXa1+5uLk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=qjZrJbBlQxrgbzsbBZp0qOBZ5BDR26UIx4EwC3o0qNn1EtiboliYem6DOz7YCzImY x1q8TbvoX2wqV9n+NmvEsniWwIaZnedX+GFBVAxTdxIFKIcH1u60CKx4/PLuy4HxaP 3Z98pBYyX8kckcRhqU4JIPdaTKcGD5YXdqsq0WY0= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Zhenwei Pi , "Michael S. Tsirkin" , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com, Peter Xu , Fabiano Rosas , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "yc-core@yandex-team.ru" , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v4 3/5] vmstate: introduce VMSTATE_VBUFFER_UINT64 Date: Mon, 29 Dec 2025 15:21:10 +0500 Message-Id: <20251229102107.1291790-4-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> References: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1767003786600158500 Content-Type: text/plain; charset="utf-8" This is an analog of VMSTATE_VBUFFER_UINT32 macro, but for uint64 type. Signed-off-by: Alexandr Moshkov Acked-by: Peter Xu --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 7f1f1c166a..4c9e212d58 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -707,6 +707,16 @@ extern const VMStateInfo vmstate_info_qlist; .offset =3D offsetof(_state, _field), \ } =20 +#define VMSTATE_VBUFFER_UINT64(_field, _state, _version, _test, _field_siz= e) { \ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .field_exists =3D (_test), \ + .size_offset =3D vmstate_offset_value(_state, _field_size, uint64_t),\ + .info =3D &vmstate_info_buffer, \ + .flags =3D VMS_VBUFFER | VMS_POINTER, \ + .offset =3D offsetof(_state, _field), \ +} + #define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \ _test, _field_size) { \ .name =3D (stringify(_field)), \ --=20 2.34.1 From nobody Wed Jan 7 09:29:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1767003778; cv=none; d=zohomail.com; s=zohoarc; b=KRQfpWGBy80gWZAMU51N/NAI3fUBwTMznTRDRppNlWRx7QQSqBhy8cxjINAzU912DOqQQYFtH+2SgnUGG8KRDUIimXkrn5f367GphLSxkLdQRmGxwcVPJI9DmpLk62nXbR/LXAjqUa80AvENt6v/hCb8QYBQf2abjo6nf2NrrnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767003778; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6zojJkt0qOBglpqzi8iocqqDo7rcIDnOuWaqGsekC9c=; b=Ji7ABbW+XyaKFBaykrl2EplDJrfMWtjfRVxSdN+2p1QtNPmzxFgNEJkf35mw4X9n7rTkw+6vOgcjp3snQn94w1QRBhGyj6WnXobT57z4mGRdsCyPVz/6W4HwRpPfaYWmsXQX3M3XUUPl4c3wGUA6Cp6wzBW7n8SkifWIZmC6UY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17670037783449.289650466976695; Mon, 29 Dec 2025 02:22:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaAOs-00017u-Oc; Mon, 29 Dec 2025 05:22:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOc-0000gW-Un; Mon, 29 Dec 2025 05:22:42 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOb-0005Sd-Ar; Mon, 29 Dec 2025 05:22:38 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 5B17EC01A6; Mon, 29 Dec 2025 13:22:35 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:b4e::1:2a]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id HLeDGC1Ck0U0-Cj4khtEr; Mon, 29 Dec 2025 13:22:34 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1767003754; bh=6zojJkt0qOBglpqzi8iocqqDo7rcIDnOuWaqGsekC9c=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=QA79bOi8BFvmjl87GPgXO+fENyuFdmBOOHZ3aJep/wA1LBl+pEHKFLMqKH2wRLkRH m9reXjqhhruSkXrGABfMi1oYUfsz6pmcXSbfOD937XWnHENF1+Mws+TKWQ/QD2QQDV hEqX9nxVubEGlo+dtvLyj60foUi5gWSb2Iz/7d2Y= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Zhenwei Pi , "Michael S. Tsirkin" , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com, Peter Xu , Fabiano Rosas , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "yc-core@yandex-team.ru" , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v4 4/5] vhost: add vmstate for inflight region with inner buffer Date: Mon, 29 Dec 2025 15:21:12 +0500 Message-Id: <20251229102107.1291790-5-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> References: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1767003780374158500 Content-Type: text/plain; charset="utf-8" Prepare for future inflight region migration for vhost-user-blk. We need to migrate size, queue_size, and inner buffer. So firstly it migrate size and queue_size fields, then allocate memory for = buffer with migrated size, then migrate inner buffer itself. Signed-off-by: Alexandr Moshkov --- hw/virtio/vhost.c | 42 +++++++++++++++++++++++++++++++++++++++ include/hw/virtio/vhost.h | 6 ++++++ 2 files changed, 48 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index cb2e21bd75..368e1d33ce 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2031,6 +2031,48 @@ const VMStateDescription vmstate_backend_transfer_vh= ost_inflight =3D { } }; =20 +static int vhost_inflight_buffer_pre_load(void *opaque, Error **errp) +{ + info_report("vhost_inflight_region_buffer_pre_load"); + struct vhost_inflight *inflight =3D opaque; + + int fd =3D -1; + void *addr =3D qemu_memfd_alloc("vhost-inflight", inflight->size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEA= L, + &fd, errp); + if (*errp) { + return -ENOMEM; + } + + inflight->offset =3D 0; + inflight->addr =3D addr; + inflight->fd =3D fd; + + return 0; +} + +const VMStateDescription vmstate_vhost_inflight_region_buffer =3D { + .name =3D "vhost-inflight-region/buffer", + .pre_load_errp =3D vhost_inflight_buffer_pre_load, + .fields =3D (const VMStateField[]) { + VMSTATE_VBUFFER_UINT64(addr, struct vhost_inflight, 0, NULL, size), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_vhost_inflight_region =3D { + .name =3D "vhost-inflight-region", + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(size, struct vhost_inflight), + VMSTATE_UINT16(queue_size, struct vhost_inflight), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_vhost_inflight_region_buffer, + NULL + } +}; + const VMStateDescription vmstate_vhost_virtqueue =3D { .name =3D "vhost-virtqueue", .fields =3D (const VMStateField[]) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 94fb9a6654..453e4a745b 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -599,6 +599,12 @@ extern const VMStateDescription vmstate_backend_transf= er_vhost_inflight; vmstate_backend_transfer_vhost_inflight, \ struct vhost_inflight) =20 +extern const VMStateDescription vmstate_vhost_inflight_region; +#define VMSTATE_VHOST_INFLIGHT_REGION(_field, _state) \ + VMSTATE_STRUCT_POINTER(_field, _state, \ + vmstate_vhost_inflight_region, \ + struct vhost_inflight) + extern const VMStateDescription vmstate_vhost_dev; #define VMSTATE_BACKEND_TRANSFER_VHOST(_field, _state) \ VMSTATE_STRUCT(_field, _state, 0, vmstate_vhost_dev, struct vhost_dev) --=20 2.34.1 From nobody Wed Jan 7 09:29:05 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1767003784; cv=none; d=zohomail.com; s=zohoarc; b=GMnTQS6RYc17Lz/KD+ZS9mJndWVwYgBIukj4pbKBma++HGNgXaig/P8vio4T1JoYQENv+VlOngbwPN/vU6qaPTHcYIv7it0vWuLwYDJhvahOmRS8NFHvDBOJR/5+wzyhQ6njo8q6tnZdP3/mof51f+mrd9QIwjq3nEc7XiKX+7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767003784; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N2XWNyCs9t0bsqwkHVkqoL+40YD8szXAylBG6g1naCw=; b=JNdwemK2CSu9XSWTYklUZDYz+ZG1u4zKlCFRDMdYoRaocOViXmn3Ta2hGWJ30EO4eZUUjsmnM+I2bKSkJPW/eZ6DbNbpedADlqWV/+Nf5KltMqY7Wahjy+ykblvLjb8HNlBAv9DtzuxkuUw78zGG3X8+lVbzTbaVIESRBbT0xt0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767003784676266.86726280637413; Mon, 29 Dec 2025 02:23:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaAOw-0001NC-3j; Mon, 29 Dec 2025 05:22:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOi-0000wU-To; Mon, 29 Dec 2025 05:22:47 -0500 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaAOh-0005T6-8A; Mon, 29 Dec 2025 05:22:44 -0500 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:7394:0:640:5a8a:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 88BE7C0162; Mon, 29 Dec 2025 13:22:41 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:b4e::1:2a]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id HLeDGC1Ck0U0-qNs34U8N; Mon, 29 Dec 2025 13:22:40 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1767003760; bh=N2XWNyCs9t0bsqwkHVkqoL+40YD8szXAylBG6g1naCw=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=oB1em2Ox4OueS40aRH7x1OxNHAO4w/C6j/++W/raIrnbVh/+4BQVOSIkCSwyIe4vv sxPJFGGxqygevIQXbQmOGgF1T6JWKgvU/EwY7lbqBIbxMnqjAXUa+EzXI1wheWcKl1 nM+ZQkQZ5noH4LWsYopsZl3oaFhXN24WVQlcahlI= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Zhenwei Pi , "Michael S. Tsirkin" , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com, Peter Xu , Fabiano Rosas , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "yc-core@yandex-team.ru" , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v4 5/5] vhost-user-blk: support inter-host inflight migration Date: Mon, 29 Dec 2025 15:21:14 +0500 Message-Id: <20251229102107.1291790-6-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> References: <20251229102107.1291790-1-dtalexundeer@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1767003786616158500 Content-Type: text/plain; charset="utf-8" During inter-host migration, waiting for disk requests to be drained in the vhost-user backend can incur significant downtime. This can be avoided if QEMU migrates the inflight region in vhost-user-blk. Thus, during the qemu migration, the vhost-user backend can cancel all inflight requests and then, after migration, they will be executed on another host. In vhost_user_blk_stop() on incoming inter-host migration make should_drain =3D true, so after GET_VRING_BASE message all in-flight requests will be migrated to other vm Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 25 +++++++++++++++++++++++++ include/hw/virtio/vhost-user-blk.h | 1 + 2 files changed, 26 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 56d55c18c8..c537e7ef9b 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -242,6 +242,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) =20 force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); + should_drain =3D !s->inflight_migration; =20 s->dev.backend_transfer =3D s->dev.backend_transfer || (runstate_check(RUN_STATE_FINISH_MIGRATE) && @@ -657,6 +658,24 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Virt= IODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_inflight_needed(void *opaque) +{ + struct VHostUserBlk *s =3D opaque; + + return s->inflight_migration && + !migrate_local_vhost_user_blk(); +} + +static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { + .name =3D "vhost-user-blk/inflight", + .version_id =3D 1, + .needed =3D vhost_user_blk_inflight_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), + VMSTATE_END_OF_LIST() + }, +}; + static bool vhost_user_blk_pre_incoming(void *opaque, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(opaque); @@ -679,6 +698,10 @@ static const VMStateDescription vmstate_vhost_user_blk= =3D { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_vhost_user_blk_inflight, + NULL + } }; =20 static bool vhost_user_needed(void *opaque) @@ -752,6 +775,8 @@ static const Property vhost_user_blk_properties[] =3D { VIRTIO_BLK_F_WRITE_ZEROES, true), DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk, skip_get_vring_base_on_force_shutdown, false), + DEFINE_PROP_BOOL("inflight-migration", VHostUserBlk, + inflight_migration, false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index b06f55fd6f..e1466e5cf6 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -52,6 +52,7 @@ struct VHostUserBlk { bool started_vu; =20 bool skip_get_vring_base_on_force_shutdown; + bool inflight_migration; =20 bool incoming_backend; }; --=20 2.34.1