From nobody Mon Sep 28 01:21:22 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=1785742207; cv=none; d=zohomail.com; s=zohoarc; b=jG9sSWzbiJOtXBUMbLqzvPP++nN1NjZmn9zJtT7/nyKFiK/gYKzlpJ+V+fVcKJB0AHPoU3Xj7auo9dr0qteonpB0JNKY091iLdFf7tNRsKQ97oIbs3vjEvHpRZJyD25YeZdhZ3AqvA5Mzb+/5FohQTcDcx3rj+qluteIVoFQCLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742207; 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=iSRfiVuk1wth5RJuqWTYKlTX2s0R3hHUfPsUzTQ8cD8=; b=T9lrK3VoDb0DFnBIt/qKDKQSXU+qB/8HAYa0AVQ/gS+HkkIstvB0DeIppZrKsafv0ffQxnp9ErZHgVshO7P6MT7+bo7GF1XS9UDH/wLqLAJW8zwSX2opu+QXdpLT2Bac11f1TqYvdZWa6XUWj791MihLhZ6gSLknaH6z0QMCJlM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785742206545466.91435243163824; Mon, 3 Aug 2026 00:30:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn79-0003N0-3R; Mon, 03 Aug 2026 03:29:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn71-0003Jl-1G; Mon, 03 Aug 2026 03:29:27 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1wqn6v-0005x9-Ly; Mon, 03 Aug 2026 03:29:25 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id C249D80D4E; Mon, 03 Aug 2026 10:29:15 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-xdSajdkB; Mon, 03 Aug 2026 10:29:15 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742155; bh=iSRfiVuk1wth5RJuqWTYKlTX2s0R3hHUfPsUzTQ8cD8=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=SdiU7zeXXkVsGit4j4qi7Y/O721GpTOHSPRQ6+LuSbetCgPizo001zn0VaZqA8FAW At6+Lp0Q3rPdrFK4JSW227epj6XZ1nv39yHouvUbGjbzH4gTidI3pmFsI9qn0S3lez 8Q9Kqwmdq9oDWjgNZb03INJFl2YGD5ioyr6FHoWc= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 1/6] vhost-user: add skip_drain param to do_vhost_virtqueue_stop Date: Mon, 3 Aug 2026 12:28:48 +0500 Message-Id: <20260803072853.2920007-2-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742209712158500 Content-Type: text/plain; charset="utf-8" Currently do_vhost_virtqueue_stop always sends GET_VRING_BASE to the back-end, which requires the back-end to drain all in-flight I/O before stopping the vring. Add a skip_drain parameter to do_vhost_virtqueue_stop and propagate it up through vhost_virtqueue_stop, vhost_dev_stop and their callers. The parameter will be used in a follow-up commit to send a new protocol message that instructs the back-end to suspend in-flight I/O immediately instead of draining it. Signed-off-by: Alexandr Moshkov --- backends/cryptodev-vhost.c | 2 +- backends/vhost-user.c | 2 +- hw/block/vhost-user-blk.c | 2 +- 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 | 28 +++++++++++++++++++--------- include/hw/virtio/vhost.h | 7 +++++-- 12 files changed, 38 insertions(+), 24 deletions(-) diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index c6069f4e5b..f1ca6bcd4e 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, false); vhost_dev_disable_notifiers(&crypto->dev, dev); } =20 diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 380d825023..0423c2d4ec 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, false); =20 if (k->set_guest_notifiers && (err =3D k->set_guest_notifiers(qbus->parent, b->dev.nvqs, false))= < 0) { diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index b2e46eb3f9..e3b873af7c 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -232,7 +232,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) qemu_force_shutdown_requested(); =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, false); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 323d117735..6e05c995f1 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, false); 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, false); 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, + false); } =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, false); =20 return r; } diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index e19800a0bc..e546a6dc75 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, false); =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 94188d37bb..b86d0b664a 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -300,7 +300,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, false); =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 39b5e637fc..abeae1a064 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -78,7 +78,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, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 209993918a..0d8842817a 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, false); =20 err =3D k->set_guest_notifiers(qbus->parent, fs->vhost_dev.nvqs, false= ); if (err < 0) { diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 9470f68c1f..9fa65d7d8b 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, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); if (err < 0) { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index b79f4c9ce6..4ef037627b 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, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vvc->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index af41841b52..2a62550222 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -23,6 +23,7 @@ #include "qemu/log.h" #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user.h" #include "hw/mem/memory-device.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" @@ -1496,8 +1497,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 skip_drain) { + if (skip_drain) { + assert(vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + } 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, @@ -1547,9 +1553,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 skip_drain) { - return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false); + return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false, skip_drain); } =20 static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev, @@ -2302,7 +2309,8 @@ fail_vq: vhost_virtqueue_stop(hdev, vdev, hdev->vqs + i, - hdev->vq_index + i); + hdev->vq_index + i, + false); } =20 fail_mem: @@ -2317,7 +2325,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 skip_drain) { int i; int rc =3D 0; @@ -2344,7 +2352,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, = VirtIODevice *vdev, vdev, hdev->vqs + i, hdev->vq_index + i, - force); + force, + skip_drain); } if (hdev->vhost_ops->vhost_reset_status) { hdev->vhost_ops->vhost_reset_status(hdev); @@ -2366,15 +2375,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 skip_drain) { - return do_vhost_dev_stop(hdev, vdev, vrings, false); + return do_vhost_dev_stop(hdev, vdev, vrings, false, skip_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 684bafcaad..33b88f95ea 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -228,6 +228,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 + * @skip_drain: true to notice back-end to skip draining all in-flight req= uests * * Stop the vhost device. After the device is stopped the notifiers * can be disabled (@vhost_dev_disable_notifiers) and the device can @@ -235,7 +236,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 skip_drain); =20 /** * vhost_dev_force_stop() - force stop the vhost device @@ -393,7 +395,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 skip_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 Mon Sep 28 01:21:22 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=1785742204; cv=none; d=zohomail.com; s=zohoarc; b=f+M38n6FAux/uga66fFoYndlFioSES+irHETnSMQD+GwJrGESjYoNjOYp/Z7k4VnTw+ZCgvA7bSpM3/b+dEl8vPJl0UJ6wWJ11E9Xi3DqUczyZ+c9AoYxNpLDyPd19vWrVsVQUXtZeOcTCekHUL6N365tqGCaBZ+U47xZjZLdyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742204; 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=Pmk2TrZwjmXDYQO/Ge9UB/SVoMr6mVj7zf1SkUUI1Zk=; b=RtNARiMxa4Ki1QUiIMeg4CFbUYtku/G8VntRy3PmOWEON6IQ6Pi4lKsTq+QPpG1mCDJh6N/0cDWMCgCIVb2yOTv2lxZ+YuAUr2VaBTMhe5+Mu4754OP1iiTInYe4UDdxfZfLM9PisiXfZdtyAq/vn2NPlURlB8WA/mrDbAa3bRg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178574220408142.91024765117629; Mon, 3 Aug 2026 00:30:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn76-0003Lb-Sb; Mon, 03 Aug 2026 03:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn71-0003Jk-0x; Mon, 03 Aug 2026 03:29:27 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1wqn6v-0005zA-MV; Mon, 03 Aug 2026 03:29:24 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id 7533380D83; Mon, 03 Aug 2026 10:29:18 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-TjBh9Qg7; Mon, 03 Aug 2026 10:29:17 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742157; bh=Pmk2TrZwjmXDYQO/Ge9UB/SVoMr6mVj7zf1SkUUI1Zk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=ToGHHgqv6Y+nvCvV+2BzWYLZEvrQv8ONW5/n5eNRLblWCRPmqMD+SftjdG6HaVj6H UhM8b2e20AQGF/wd2zX6RqUUgwKgfmgiDgMrTjizPP+YPmbzkAZfvEy3zEhh+AUrHe 6NSF1jQ6wCMu2BPGhrSt+JG9CF2d/Jk2Bg8YD4Bs= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 2/6] vhost-user: add GET_VRING_BASE_SKIP_DRAIN message Date: Mon, 3 Aug 2026 12:28:49 +0500 Message-Id: <20260803072853.2920007-3-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742207539158500 Content-Type: text/plain; charset="utf-8" VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT was introduced to allow the back-end to suspend in-flight I/O during GET_VRING_BASE instead of draining it, enabling live migration of in-flight requests. However, this behaviour is tied to the protocol feature itself - once negotiated, there is no way for the front-end to tell the back-end to fall back to the normal drain behaviour on a per-stop basis. Introduce a separate message VHOST_USER_GET_VRING_BASE_SKIP_DRAIN (id=3D45) guarded by a new protocol feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN. The message is identical to GET_VRING_BASE except that the back-end must immediately suspe= nd all in-flight I/O and record it in the inflight region. This way the front-end has explicit per-call control: send GET_VRING_BASE for normal dra= in, send GET_VRING_BASE_SKIP_DRAIN when immediate suspend is needed. The new feature requires both VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT and VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD to be negotiated. Signed-off-by: Alexandr Moshkov --- docs/interop/vhost-user.rst | 88 +++++++++++++++++++------------ hw/virtio/vhost-user.c | 44 ++++++++++++++-- hw/virtio/vhost.c | 2 +- include/hw/virtio/vhost-backend.h | 1 + include/hw/virtio/vhost-user.h | 1 + 5 files changed, 95 insertions(+), 41 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index c83ae2accb..d2e0efaeaa 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -445,6 +445,7 @@ replies, except for the following requests: * ``VHOST_USER_GET_FEATURES`` * ``VHOST_USER_GET_PROTOCOL_FEATURES`` * ``VHOST_USER_GET_VRING_BASE`` +* ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` * ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``) * ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMF= D``) =20 @@ -523,7 +524,7 @@ must start a ring upon receiving a kick (that is, detec= ting that file descriptor is readable) on the descriptor specified by ``VHOST_USER_SET_VRING_KICK`` or receiving the in-band message ``VHOST_USER_VRING_KICK`` if negotiated, and stop a ring upon receiving -``VHOST_USER_GET_VRING_BASE``. +``VHOST_USER_GET_VRING_BASE`` or ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN``. =20 Rings can be enabled or disabled by ``VHOST_USER_SET_VRING_ENABLE``. =20 @@ -1101,29 +1102,30 @@ Protocol features =20 .. code:: c =20 - #define VHOST_USER_PROTOCOL_F_MQ 0 - #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 - #define VHOST_USER_PROTOCOL_F_RARP 2 - #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 - #define VHOST_USER_PROTOCOL_F_MTU 4 - #define VHOST_USER_PROTOCOL_F_BACKEND_REQ 5 - #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 - #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7 - #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8 - #define VHOST_USER_PROTOCOL_F_CONFIG 9 - #define VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD 10 - #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 - #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 - #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 - #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14 - #define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15 - #define VHOST_USER_PROTOCOL_F_STATUS 16 - #define VHOST_USER_PROTOCOL_F_XEN_MMAP 17 - #define VHOST_USER_PROTOCOL_F_SHARED_OBJECT 18 - #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 - #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 - #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 - #define VHOST_USER_PROTOCOL_F_SHMEM_MAP 22 + #define VHOST_USER_PROTOCOL_F_MQ 0 + #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 + #define VHOST_USER_PROTOCOL_F_RARP 2 + #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 + #define VHOST_USER_PROTOCOL_F_MTU 4 + #define VHOST_USER_PROTOCOL_F_BACKEND_REQ 5 + #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 + #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7 + #define VHOST_USER_PROTOCOL_F_PAGEFAULT 8 + #define VHOST_USER_PROTOCOL_F_CONFIG 9 + #define VHOST_USER_PROTOCOL_F_BACKEND_SEND_FD 10 + #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 + #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 + #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 + #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14 + #define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15 + #define VHOST_USER_PROTOCOL_F_STATUS 16 + #define VHOST_USER_PROTOCOL_F_XEN_MMAP 17 + #define VHOST_USER_PROTOCOL_F_SHARED_OBJECT 18 + #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 + #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 + #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 + #define VHOST_USER_PROTOCOL_F_SHMEM_MAP 22 + #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN 23 =20 Front-end message types ----------------------- @@ -1320,17 +1322,11 @@ Front-end message types set to 0. =20 By default, the back-end must complete all inflight I/O requests for the - specified vring before stopping it. - - If the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` protocol - feature has been negotiated, the back-end may suspend in-flight I/O - requests and record them as described in :ref:`Inflight I/O tracking - ` instead of completing them before stopping the v= ring. - How to suspend an in-flight request depends on the implementation of the= back-end - but it typically can be done by aborting or cancelling the underlying I/O - request. The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` - protocol feature must only be negotiated if - ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` is also negotiated. + specified vring before stopping it. If the + ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature has + been negotiated, the front-end may instead use + ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` to request the back-end to + suspend in-flight I/O immediately. =20 ``VHOST_USER_SET_VRING_KICK`` :id: 12 @@ -1833,6 +1829,28 @@ Front-end message types =20 * The size may be 0 if the region is unused. =20 +``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` + :id: 45 + :equivalent ioctl: N/A + :request payload: vring state description + :reply payload: vring descriptor index/indices + + This message requires the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DR= AIN`` + protocol feature to be negotiated. + + Identical to ``VHOST_USER_GET_VRING_BASE`` except that the back-end + must not wait for inflight I/O requests to complete before stopping + the vring. Instead, the back-end must immediately suspend all + in-flight I/O requests and record them as described in + :ref:`Inflight I/O tracking `. How to suspend + an in-flight request depends on the implementation of the back-end, + but it typically can be done by aborting or cancelling the underlying + I/O request. + + The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature + must only be negotiated if both ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_I= NFLIGHT`` + and ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` are also negotiated. + Back-end message types ---------------------- =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index d627351f45..58b142cbee 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -101,6 +101,7 @@ typedef enum VhostUserRequest { VHOST_USER_SET_DEVICE_STATE_FD =3D 42, VHOST_USER_CHECK_DEVICE_STATE =3D 43, VHOST_USER_GET_SHMEM_CONFIG =3D 44, + VHOST_USER_GET_VRING_BASE_SKIP_DRAIN =3D 45, VHOST_USER_MAX } VhostUserRequest; =20 @@ -167,6 +168,7 @@ static const char *vhost_req_name(VhostUserRequest req) VHOST_USER_CASE(GET_SHARED_OBJECT) VHOST_USER_CASE(SET_DEVICE_STATE_FD) VHOST_USER_CASE(CHECK_DEVICE_STATE) + VHOST_USER_CASE(GET_VRING_BASE_SKIP_DRAIN) default: return ""; } @@ -1399,12 +1401,18 @@ static VhostUserHostNotifier *fetch_notifier(VhostU= serState *u, return g_ptr_array_index(u->notifiers, idx); } =20 -static int vhost_user_get_vring_base(struct vhost_dev *dev, - struct vhost_vring_state *ring) +static int get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring, + bool skip_drain) { int ret; + int request =3D VHOST_USER_GET_VRING_BASE; + if (skip_drain) { + request =3D VHOST_USER_GET_VRING_BASE_SKIP_DRAIN; + } + VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_GET_VRING_BASE, + .hdr.request =3D request, .hdr.flags =3D VHOST_USER_VERSION, .payload.state =3D *ring, .hdr.size =3D sizeof(msg.payload.state), @@ -1424,9 +1432,9 @@ static int vhost_user_get_vring_base(struct vhost_dev= *dev, return ret; } =20 - if (msg.hdr.request !=3D VHOST_USER_GET_VRING_BASE) { + if (msg.hdr.request !=3D request) { error_report("Received unexpected msg type. Expected %d received %= d", - VHOST_USER_GET_VRING_BASE, msg.hdr.request); + request, msg.hdr.request); return -EPROTO; } =20 @@ -1440,6 +1448,25 @@ static int vhost_user_get_vring_base(struct vhost_de= v *dev, return 0; } =20 +static int vhost_user_get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return get_vring_base(dev, ring, false); +} + +static int vhost_user_get_vring_base_skip_drain(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + bool skip_drain_supported =3D vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (!skip_drain_supported) { + return 0; + } + + return get_vring_base(dev, ring, true); +} + static int vhost_set_vring_file(struct vhost_dev *dev, VhostUserRequest request, struct vhost_vring_file *file) @@ -2551,6 +2578,12 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); } =20 + if (!virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT= )) { + protocol_features &=3D ~(1ULL << + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRA= IN); + } + /* final set of protocol features */ u->protocol_features =3D protocol_features; err =3D vhost_user_set_protocol_features(dev, u->protocol_features= ); @@ -3409,6 +3442,7 @@ const VhostOps user_ops =3D { .vhost_set_vring_num =3D vhost_user_set_vring_num, .vhost_set_vring_base =3D vhost_user_set_vring_base, .vhost_get_vring_base =3D vhost_user_get_vring_base, + .vhost_get_vring_base_skip_drain =3D vhost_user_get_vring_base_ski= p_drain, .vhost_set_vring_kick =3D vhost_user_set_vring_kick, .vhost_set_vring_call =3D vhost_user_set_vring_call, .vhost_set_vring_err =3D vhost_user_set_vring_err, diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2a62550222..2c7f464d55 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1502,7 +1502,7 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *= dev, { if (skip_drain) { assert(vhost_user_has_protocol_feature(dev, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN)); } int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index d878d7b733..daa979a1aa 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -190,6 +190,7 @@ typedef struct VhostOps { vhost_set_vring_num_op vhost_set_vring_num; vhost_set_vring_base_op vhost_set_vring_base; vhost_get_vring_base_op vhost_get_vring_base; + vhost_get_vring_base_op vhost_get_vring_base_skip_drain; vhost_set_vring_kick_op vhost_set_vring_kick; vhost_set_vring_call_op vhost_set_vring_call; vhost_set_vring_err_op vhost_set_vring_err; diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 06c360af18..47c13f8677 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -36,6 +36,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT =3D 20, VHOST_USER_PROTOCOL_F_GPA_ADDRESSES =3D 21, VHOST_USER_PROTOCOL_F_SHMEM =3D 22, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN =3D 23, VHOST_USER_PROTOCOL_F_MAX }; =20 --=20 2.34.1 From nobody Mon Sep 28 01:21:22 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=1785742196; cv=none; d=zohomail.com; s=zohoarc; b=nvHjYNx+djOi+G1x1AnR38ArzHk1Tv3f5WW0GjVdacMfKv6IKha/LXzqB1miKm7XWwGrDIM9cmTqp729DVD3vqwZCb5QSv1GoG06f+5VKhgVN3Itp0/ABnMcjZc4ft7cIYiai2tWHqs9S0UDrJzLaHOgicUtPl6oQv2jc7gj+p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742196; 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=PfoLHGcOutgg0hQy+Phc11/k5TDb5rZJ1aU6PrMxzJE=; b=eCkFZYcHCjc0D7SW88gZ0bbx603MAORSBt6XPgVIYkxCm49JjVGMIYFZCpwraqrzJ7zN3qx0CtdWrUPVhrchtAQE63rC/Z07tvCfcILRQv8nIvQQc4N/mOPztttDvPdSx+/pLukLfOaSLawwEEmLYElElXjTImmvTsBQg3ErAJo= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785742196363823.5547302660959; Mon, 3 Aug 2026 00:29:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn79-0003Nc-Gu; Mon, 03 Aug 2026 03:29:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn72-0003K7-3H; Mon, 03 Aug 2026 03:29:28 -0400 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn6w-0005zQ-Of; Mon, 03 Aug 2026 03:29:27 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id E1B4A80D87; Mon, 03 Aug 2026 10:29:19 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-SMShGnnU; Mon, 03 Aug 2026 10:29:19 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742159; bh=PfoLHGcOutgg0hQy+Phc11/k5TDb5rZJ1aU6PrMxzJE=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=U3EvXVcdrWgdge0M+ffIllYAF6K2vCyVtBlrQWBor34dhHeTJ1xhY3JNKRg2nDR10 pvBWOySljTxmYyC5MuWWeLqIbD/vdCdV0+tZmpJUlSYCEeLx68CwIiNvdteUHnU2r1 owl42v5qhjBsnvRWi3FWl9HG1uw9mTqWzzVXrrE0= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 3/6] vhost-user: use skip_drain with GET_VRING_BASE_SKIP_DRAIN message Date: Mon, 3 Aug 2026 12:28:50 +0500 Message-Id: <20260803072853.2920007-4-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=178.154.239.200; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742197741158500 Content-Type: text/plain; charset="utf-8" Wire up the skip_drain parameter introduced in the previous commit to the new GET_VRING_BASE_SKIP_DRAIN message. When skip_drain is set, send GET_VRING_BASE_SKIP_DRAIN instead of GET_VRING_BASE, instructing the back-end to suspend in-flight I/O immediately. Signed-off-by: Alexandr Moshkov --- hw/virtio/vhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2c7f464d55..bd079f9080 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1518,7 +1518,11 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, } =20 if (!force) { - r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + if (!skip_drain) { + r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + } else { + r =3D dev->vhost_ops->vhost_get_vring_base_skip_drain(dev, &st= ate); + } if (r < 0) { VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx,= r); } --=20 2.34.1 From nobody Mon Sep 28 01:21:22 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=1785742185; cv=none; d=zohomail.com; s=zohoarc; b=Fe4pqVkKRIrAO7+33jrtHtTe9hZvPS1AjAt+GcOKl5/wIYIbhomPq1EYhywGtArRLN5joC2G8mNz9JicwVqZ2SBpzWUtylUrTqBE1GmH/5E7PIBizotk4KjWoy6yDFhr1faanIqgd9VWc8Byv5x9p4AHK6M0Wrwqr+pvN05q158= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742185; 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=16lP9WkId4tMUMj/wHCbByTfSWJyYK7Hisx0zTCruhY=; b=HhktERQ4ora6Znpk87Z2a/whejmRk1vT0I1xTHyjPa/Daa9lLmBrjYsI2iq3hQQGDyeUPQ8Tn1644Xhhy2AHDlrbUygiv/9md75EVvqy+G67zdRnIGOohFvbxd8/ZQduFn6kvcuUEaeCb/PXq1GTYd1tT/LSJNudIhFVBQMB6TA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785742185000988.35382951782; Mon, 3 Aug 2026 00:29:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn76-0003Ld-Vj; Mon, 03 Aug 2026 03:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn73-0003KQ-CN; Mon, 03 Aug 2026 03:29:29 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1wqn71-0005zl-3Z; Mon, 03 Aug 2026 03:29:29 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id A1D0880D53; Mon, 03 Aug 2026 10:29:21 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-3qVFiAP3; Mon, 03 Aug 2026 10:29:21 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742161; bh=16lP9WkId4tMUMj/wHCbByTfSWJyYK7Hisx0zTCruhY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=O7dzMKJEKvy95xMQuC7D3PynJehYXBvS4eiuHrL1ATVe9NMjqvl/p13faJ1L0/X3F vsDBDAIcUiF1cxKeTkTdJ7Zb4/t77uuxjzDIXnpzOAmVGaLZ7ce7KsKUrIU1kIgCqH yToUViiYuRpcKiUo2BBd0i0lpcq1qsYaD+IOj3Lw= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 4/6] vhost-user-blk: make inflight-migration prop mutable on running vm Date: Mon, 3 Aug 2026 12:28:51 +0500 Message-Id: <20260803072853.2920007-5-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742188066158500 Content-Type: text/plain; charset="utf-8" The inflight-migration property currently can only be set before the device is realized. This makes it impossible to disable inflight migration at runtime without restarting the VM. Make the property mutable, but only while the VM is running. Blocking changes when the VM is not running ensures that the value at stop time reliably reflects the intent set on a live VM, which allows vhost_user_blk_stop() to use skip_drain unconditionally based on the property value without inspecting migration runstate. Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e3b873af7c..1aec3004de 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -619,6 +619,8 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { } }; =20 +static PropertyInfo vhost_user_blk_inflight_migration_prop; + static const Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, @@ -632,8 +634,9 @@ 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), + DEFINE_PROP("inflight-migration", VHostUserBlk, inflight_migration, + vhost_user_blk_inflight_migration_prop, bool, + .set_default =3D true, .defval.u =3D false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) @@ -663,8 +666,29 @@ static const TypeInfo vhost_user_blk_info =3D { .class_init =3D vhost_user_blk_class_init, }; =20 +static void vhost_user_blk_set_inflight_migration(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **er= rp) +{ + DeviceState *dev =3D DEVICE(obj); + + if (dev->realized && !runstate_is_running()) { + error_setg(errp, "Property '%s' cannot be changed " + "while VM is not running", name); + return; + } + + qdev_prop_bool.set(obj, v, name, opaque, errp); +} + + static void virtio_register_types(void) { + vhost_user_blk_inflight_migration_prop =3D qdev_prop_bool; + vhost_user_blk_inflight_migration_prop.realized_set_allowed =3D true; + vhost_user_blk_inflight_migration_prop.set =3D + vhost_user_blk_set_inflight_migration; + type_register_static(&vhost_user_blk_info); } =20 --=20 2.34.1 From nobody Mon Sep 28 01:21:22 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=1785742204; cv=none; d=zohomail.com; s=zohoarc; b=Ey66elOUOi52bGLFu4v6wCwuw8AG2qmq/YgwIBYOalYaAyUvJondWjpWVsk/IGfazTiMiMwRZYK4d4Yi0fp9utbIqwtZimJD07d+k1JZfBH/XarC511wjfzlHlMWYZgZREPUHnAiTLOjDlJNFQJdKugGRExlz55GjXGY3L7+vsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742204; 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=sCc3cRm00jDODlA2ejp7X5uiHLJyu3SZc0Q/nAi9T2M=; b=GYVim0vcK0iHmGeTwGSNFSvwAW+8bcgB10RX8JEqdaMMBy6Z9HZ7hrjvy1SaGIMMpwXJpFmFvpWjCPhI2aQY4SKVt5mI68sbE82wsLkIKd/v41VXaLSpTKTsTxZZz6fXMQFsSEuuswTW1Id0AFq6e+nePOojCexeB5wSeeJiCdg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785742204025998.8821860481794; Mon, 3 Aug 2026 00:30:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn76-0003La-Is; Mon, 03 Aug 2026 03:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn73-0003KR-Hy; Mon, 03 Aug 2026 03:29:29 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1wqn71-0005zw-4i; Mon, 03 Aug 2026 03:29:29 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id E3AB080B3C; Mon, 03 Aug 2026 10:29:22 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-K1yHyWne; Mon, 03 Aug 2026 10:29:22 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742162; bh=sCc3cRm00jDODlA2ejp7X5uiHLJyu3SZc0Q/nAi9T2M=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=Zp+3dJlbbIEsHhxoGwaJMQvWQ51hBc/gTXgdLENaI3qeTBDWn5xUc1NC6Tovoa0Gq Rqb4fx7EMvQewEXzvcmSV4mVI7FCdFccs1+TuBaenChcbG4sbnMRErf/b8hYYtnFR9 HY37e1ezlG7XgwFPXltL4iq86+vexHoQiX58gGu4= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 5/6] vhost-user-blk: move inflight_needed higher Date: Mon, 3 Aug 2026 12:28:52 +0500 Message-Id: <20260803072853.2920007-6-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742207412158500 Content-Type: text/plain; charset="utf-8" Move vhost_user_blk_inflight_needed() earlier in the file so it can be called from vhost_user_blk_stop(), which is defined before the VMState section. No functional change. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 1aec3004de..7a7e1a6d19 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,6 +131,17 @@ const VhostDevConfigOps blk_ops =3D { .vhost_dev_config_notifier =3D vhost_user_blk_handle_config_change, }; =20 +static bool vhost_user_blk_inflight_needed(void *opaque) +{ + struct VHostUserBlk *s =3D opaque; + + bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); + + return inflight_migration; +} + + static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); @@ -587,14 +598,6 @@ 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 vhost_user_has_protocol_feature( - &s->dev, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT); -} - static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { .name =3D "vhost-user-blk/inflight", .version_id =3D 1, --=20 2.34.1 From nobody Mon Sep 28 01:21:22 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=1785742262; cv=none; d=zohomail.com; s=zohoarc; b=MN58wnfylH5+Hi35HbiSFeSnFAavpaQ3iK3DvO6AKW9cz48VFfz2BBRupg0NMA9E4ou2AhldimtCwEaaxTLsq+thU4e1tYQe4N+6rpELqhWF/WJbdFDz/ONebcJPzCaI+07gU9iXjkEXVi9NK5xSIQSfcUkNGofMpY79HpiJtJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785742262; 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=jmKCJp1iaPfwL9g4BXdCpfOJn8v1FlQIelet4JuFyoc=; b=GELcM3RHeFaonNqHP5o+B/0z17wuNd7KJsvb5c0jpcI1e/bD01eE4BSsoblSXXU4+CVtq98AfOrkgAShsrGQ1XldEHDUIWkvuWqxjO9C9atZXS820mkbOrw0x7Y5DZd8OOxzvTETlysmuV7HJSW3VxPRP3nmd0mAXK9Zcf6RUqg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785742262707920.7369382492687; Mon, 3 Aug 2026 00:31:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqn78-0003Lz-8J; Mon, 03 Aug 2026 03:29:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqn73-0003Ke-Rp; Mon, 03 Aug 2026 03:29:30 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1wqn71-00060F-5H; Mon, 03 Aug 2026 03:29:29 -0400 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (postfix) with ESMTPS id 5815A80D93; Mon, 03 Aug 2026 10:29:24 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:a53::1:f]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp) with ESMTPSA id rSdSxZ08oGk0-tOK2oaWC; Mon, 03 Aug 2026 10:29:23 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785742163; bh=jmKCJp1iaPfwL9g4BXdCpfOJn8v1FlQIelet4JuFyoc=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=xBrWYAFgGo4O3RPDUtbj95WirrfSSW8a3x9gkhJFoyk/L8btLIMJr+JDpzZL2dgk1 o6AEPjgSq92inKAFcXyqwycK3AeKIswnz1+DtsnKATnMxS9dAKB1Sz/crHfzGQcQQ7 9KlJwSnf0TXb+cZRa+TDyAkHV3EH1sjT7KOCh6rU= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Stefan Hajnoczi , zhenwei pi , "Gonglei (Arei)" , Jason Wang , Kevin Wolf , Vladimir Sementsov-Ogievskiy , Milan Zamazal , Paolo Bonzini , qemu-block@nongnu.org, Hanna Reitz , "Michael S. Tsirkin" , Fam Zheng , virtio-fs@lists.linux.dev, Pierrick Bouvier , Jason Wang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Raphael Norwitz , Pierrick Bouvier , "yc-core@yandex-team.ru" , Alexandr Moshkov Subject: [PATCH v6 6/6] vhost-user-blk: use GET_VRING_BASE_SKIP_DRAIN when inflight-migration is on Date: Mon, 3 Aug 2026 12:28:53 +0500 Message-Id: <20260803072853.2920007-7-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803072853.2920007-1-dtalexundeer@yandex-team.ru> References: <20260803072853.2920007-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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1d.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, 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: qemu development 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: 1785742263775158500 Content-Type: text/plain; charset="utf-8" Currently during live migration vhost-user-blk sends GET_VRING_BASE to stop vrings, which causes the back-end to drain all in-flight I/O before returning. This blocks the migration source until all I/O completes, adding significant downtime proportional to the I/O load. When inflight-migration is enabled, send GET_VRING_BASE_SKIP_DRAIN instead. This instructs the back-end to immediately suspend in-flight I/O and record it in the shared inflight region, which is then migrated to the destination host along with the rest of the device state. Since inflight-migration can only be toggled while the VM is running, i2ts value at stop time reliably reflects the intent set on a live VM. There is no need to check migration runstate to decide whether to skip draining. Using GET_VRING_BASE_SKIP_DRAIN on a regular VM stop is safe - the back-end records any in-flight requests in the shared inflight region, and they will be resubmitted when the VM starts again via SET_INFLIGHT_FD. If the back-end does not support VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN, migration is aborted with an error in pre_save rather than hitting an assert at runtime. Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 29 +++++++++++++++++++++++------ hw/virtio/vhost-user.c | 3 +-- include/hw/virtio/vhost-user.h | 1 - 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 7a7e1a6d19..6a11dc23c3 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -135,10 +135,7 @@ static bool vhost_user_blk_inflight_needed(void *opaqu= e) { struct VHostUserBlk *s =3D opaque; =20 - bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); - - return inflight_migration; + return s->inflight_migration; } =20 =20 @@ -239,11 +236,13 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) return 0; } =20 + bool skip_drain =3D vhost_user_blk_inflight_needed(s); + force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true, false); + vhost_dev_stop(&s->dev, vdev, true, skip_drain); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { @@ -375,7 +374,6 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) vhost_dev_set_config_notifier(&s->dev, &blk_ops); =20 s->vhost_user.supports_config =3D true; - s->vhost_user.supports_inflight_migration =3D s->inflight_migration; ret =3D vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, errp); if (ret < 0) { @@ -598,10 +596,29 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Vir= tIODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_pre_save(void *opaque, Error **errp) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(opaque); + + bool inflight_migration_enabled =3D vhost_user_has_protocol_feature(&s= ->dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (vhost_user_blk_inflight_needed(s) && !inflight_migration_enabled) { + error_setg(errp, "can't migrate vhost-user-blk device: " + "backend doesn't support " + "VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN " + "protocol feature"); + return false; + } + + return true; +} + 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, + .pre_save_errp =3D vhost_user_blk_pre_save, .fields =3D (const VMStateField[]) { VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), VMSTATE_END_OF_LIST() diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 58b142cbee..c8a3d184c8 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2571,8 +2571,7 @@ static int vhost_user_backend_init(struct vhost_dev *= dev, void *opaque, } } =20 - if (!u->user->supports_inflight_migration || - !virtio_has_feature(protocol_features, + if (!virtio_has_feature(protocol_features, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { protocol_features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 47c13f8677..78b4fba27f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -73,7 +73,6 @@ typedef struct VhostUserState { GPtrArray *notifiers; int memory_slots; bool supports_config; - bool supports_inflight_migration; } VhostUserState; =20 /** --=20 2.34.1