From nobody Tue Feb 10 13:19:56 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=1768464747; cv=none; d=zohomail.com; s=zohoarc; b=XqisjdrPcL7ZWErfFKpj4i01ibFvnTdNVObvhrNxTvqVCs6jvOBkgb3MSqak1tdK3gL9E15IXI0RV1BWXPke2cEAHuTq2/NzozmtY3N5PsYRrrLH/Rt/9/KA9rPin8gZOMrtjOu8v4zmu67siZ0TULX/80pJWLTrTrWPNdAW+d4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768464747; 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=9PPLyoAF9uKjuVtoYn1MDGNfeL/dGnEkHlCxh6noEqU=; b=MyPbmmbfcSEaepEuLlaNuxuK3LNwWSCP5rRQ3ycuxLwoqrQor4gnDP94mLLoqGJrZw4YAu7Nm7q8zZhkFaig357tpPtT4BzdcvjmB7lg5NJuhkWglcSVKFsyV0BH7nRywgJ1qFPUVg0nokCDsYjcZlWSqTlvFn4oQqwzO1tOuTw= 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 1768464747443780.7559404954532; Thu, 15 Jan 2026 00:12:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgISP-0002cZ-TK; Thu, 15 Jan 2026 03:11:55 -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 1vgISK-0002bM-6j; Thu, 15 Jan 2026 03:11:48 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vgISI-0005tS-6m; Thu, 15 Jan 2026 03:11:47 -0500 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 9F5858079D; Thu, 15 Jan 2026 11:11:42 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:973::1:c]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id PBQgfR0Ar8c0-b6xzHH6u; Thu, 15 Jan 2026 11:11:41 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768464701; bh=9PPLyoAF9uKjuVtoYn1MDGNfeL/dGnEkHlCxh6noEqU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=wWZnlsEef2jWKtgfbUvULnFiIs2HJa/xg9SaQvvrE0mT5OE6lsWDITpYP+aZR24gu 8K9axNx4l5pENwBlC2wuCvwrfuCF4FNZe0ZwfxjjJWK+2wXU7RhJWlaiGfeICIG+ws J5LJ+DA69Umdg4WVYN+jVfQkQ733W5uIKWNuj8Kw= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.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 v7 1/5] vhost-user.rst: specify vhost-user back-end action on GET_VRING_BASE Date: Thu, 15 Jan 2026 13:11:01 +0500 Message-Id: <20260115081103.655749-2-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115081103.655749-1-dtalexundeer@yandex-team.ru> References: <20260115081103.655749-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.136; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1b.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: 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: 1768464775487158500 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 Reviewed-by: Stefan Hajnoczi --- 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 93a9c8df2b..66a8a2fbf3 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1250,7 +1250,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 Tue Feb 10 13:19:56 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=1768464762; cv=none; d=zohomail.com; s=zohoarc; b=fQOrgTK31DSmZanBKkJvLSGgDJMZdnLmsUIoxT8PdKRhBNOAAxWhIQdoW370Ebsoo8WINyRCjNeckCbASWE3W9IUZIdZUjH6Yf1hgZlBLffHoZAD9Ena0m+d8j3u6iQb4odhEMIJqeuv3JfZ3TaMT5JtFWXa4hKlG8TZSWBged4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768464762; 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=brAvgzNKEEepbNJKXXYhDnlUsoEZJ+Q5L1IfC7hUmGA=; b=Q2qClNf+2YE4yf6YbSVKIq7wbJA0u/5ughKksM/isDeMVA58Kc1MaKFAY9MhbD2toVijug16Im42TQ09yuzLROtfRN+Gm37n6JX7r7R73mZI7j3aLIy/VfjpTsMnl9Ya6aRWdGr2m+NFWh5yoaMjFiU3eLc9jZI/145ENVR+yzs= 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 1768464762176293.78424613655216; Thu, 15 Jan 2026 00:12:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgISX-0002eX-Pt; Thu, 15 Jan 2026 03:12:01 -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 1vgIST-0002dK-S0; Thu, 15 Jan 2026 03:11:57 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vgISS-0005yA-3U; Thu, 15 Jan 2026 03:11:57 -0500 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 79BAE807A9; Thu, 15 Jan 2026 11:11:54 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:973::1:c]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id PBQgfR0Ar8c0-IGupz6fw; Thu, 15 Jan 2026 11:11:53 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768464713; bh=brAvgzNKEEepbNJKXXYhDnlUsoEZJ+Q5L1IfC7hUmGA=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=driIziYdK6Sj1luY/0ZbnOQ+DRpTaRcRC4J0hDmd20pfHVT8vRlWxVIerB8YoLM2u nz2EBOplS0FUFRM1wSOUOVTjOKMI4Tuzhej0wQlvxo9HCiS9R1ditlzNaS7ikuKj4u Ep3fqu0q1M/3OVS70NEhStXV7jvo7v2ijf0cQ2O8= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.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 v7 2/5] vhost-user: introduce protocol feature for skip drain on GET_VRING_BASE Date: Thu, 15 Jan 2026 13:11:03 +0500 Message-Id: <20260115081103.655749-3-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115081103.655749-1-dtalexundeer@yandex-team.ru> References: <20260115081103.655749-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.136; envelope-from=dtalexundeer@yandex-team.ru; helo=forwardcorp1b.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: 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: 1768464765358158500 Content-Type: text/plain; charset="utf-8" Add vhost-user protocol feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT Now on GET_VRING_BASE this feature can control whether to wait for in-flight requests to complete or not. Also we have to validate that this feature will be enabled only when qemu and back-end supports in-flight buffer and in-flight migration It will be helpfull in future for in-flight requests migration in vhost-user devices. Update docs, add ref to label for inflight-io-tracking Signed-off-by: Alexandr Moshkov Reviewed-by: Stefan Hajnoczi --- docs/interop/vhost-user.rst | 59 +++++++++++++++++++++------------- hw/virtio/vhost-user.c | 7 ++++ include/hw/virtio/vhost-user.h | 2 ++ 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 66a8a2fbf3..a1afd09692 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -743,6 +743,8 @@ negotiated, back-end can send file descriptors (at most= 8 descriptors in each message) to front-end via ancillary data using this fd communication channel. =20 +.. _inflight_io_tracking: + Inflight I/O tracking --------------------- =20 @@ -1040,26 +1042,27 @@ 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_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 =20 Front-end message types ----------------------- @@ -1250,12 +1253,24 @@ 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 + 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 neogotiated if + ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` is also negotiated. + ``VHOST_USER_SET_VRING_KICK`` :id: 12 :equivalent ioctl: ``VHOST_SET_VRING_KICK`` diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 63fa9a1b4b..bb8f8eab77 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2225,6 +2225,13 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, } } =20 + if (!u->user->supports_inflight_migration || + !virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + protocol_features &=3D ~(1ULL << + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); + } + /* final set of protocol features */ dev->protocol_features =3D protocol_features; err =3D vhost_user_set_protocol_features(dev, dev->protocol_featur= es); diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 55d5725ef8..53fe996686 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -32,6 +32,7 @@ enum VhostUserProtocolFeature { /* Feature 17 reserved for VHOST_USER_PROTOCOL_F_XEN_MMAP. */ VHOST_USER_PROTOCOL_F_SHARED_OBJECT =3D 18, VHOST_USER_PROTOCOL_F_DEVICE_STATE =3D 19, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT =3D 20, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -68,6 +69,7 @@ typedef struct VhostUserState { GPtrArray *notifiers; int memory_slots; bool supports_config; + bool supports_inflight_migration; } VhostUserState; =20 /** --=20 2.34.1 From nobody Tue Feb 10 13:19:56 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=1768464750; cv=none; d=zohomail.com; s=zohoarc; b=hkBxIT7VBODwm0vBjT+leDLtcA2ahgwrprJ/7Mk/2cwm/DNe03Olzbz/vs18AGxm20vY5w2703uVqk7NLNFG/H/juVlxjQQ07MD/82VWsUJhAxa9xraHcU+3rG6MUg+810pgv3gFgIQPtoIDFrYnuyyBGsjGMKfmz9nYsfkun2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768464750; 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=nBeIMr42F2tRyBKJ/U0V/dSfZ6JJ9mJbTs32bIyfWW0=; b=KUfMh4GMGHWCCglbjl3yQfKLZpNHiV5U6LFJ6eSd/fqrZCmZX/mwcrC/mbSGVTB+93C56lR+jkP8iaxLZj5GFelMP1hybjkj3Zm/pW7waeLuHXNAFPu2RT3TA1zFvOQnG8uhlX3k0NUnrNlCcH8EE5fdTkCP3PlS80DyfZnXKsw= 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 1768464750792683.5765588390277; Thu, 15 Jan 2026 00:12:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgISq-0002n7-MI; Thu, 15 Jan 2026 03:12:20 -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 1vgISd-0002g0-2H; Thu, 15 Jan 2026 03:12:07 -0500 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 1vgISb-0005zy-KZ; Thu, 15 Jan 2026 03:12:06 -0500 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 87F6A807CA; Thu, 15 Jan 2026 11:12:02 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:973::1:c]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id PBQgfR0Ar8c0-GnWGz1AX; Thu, 15 Jan 2026 11:12:01 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768464721; bh=nBeIMr42F2tRyBKJ/U0V/dSfZ6JJ9mJbTs32bIyfWW0=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=nLcRzy8RdkS0c3Ennb4BCKa7nAVe4kmCtluCPzed3DzpILHHGbuDKeQR98DCXmvZh LKm+coEeZjSx+mryOcHE6GZVxzbcrqnPyFBrtKnDnvbIBWAyLrcKqm3GXSsWrCwIJz OplWBC9nunIKhqMkykO01yaiGF+9aipmPd917rwQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.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 v7 3/5] vmstate: introduce VMSTATE_VBUFFER_UINT64 Date: Thu, 15 Jan 2026 13:11:05 +0500 Message-Id: <20260115081103.655749-4-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115081103.655749-1-dtalexundeer@yandex-team.ru> References: <20260115081103.655749-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.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, 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: 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: 1768464752598158500 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 Reviewed-by: Stefan Hajnoczi --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index ed9095a466..89f9f49d20 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -706,6 +706,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 Tue Feb 10 13:19:56 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=1768464782; cv=none; d=zohomail.com; s=zohoarc; b=PBlFHF/kxESRdh9bp0zsArPdjVydsVVU9KT6W9/k09tS3SdEGtYlljAOm23RCfrYgxuOE9Ym8iU2T/HD6KSLGZKUH1u+f/0L9rBAP+vjvbjJ3k1TNHLXo91XG8SNWdXcMk8eNtafQYCYlvIVSUlIA5A3EpEg4WeYbPpZzWtZRUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768464782; 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=yWibqi19WvTNo5ModM1nu+rTjbF5ptLfVCEPC+ZLWJY=; b=TkcK67iX92AqeTZaNBSNrdOdylV5LK4JE1UNUOANoOoZ836hxThRUFMowzgG88ycRnlp77yy3sUI9Q+ycEAI+Xb+he9t07vXOLDNug/yLOrjHboaJ3+ydw9tyVBHXi5cOL31kZU7xKVQFP4uXhOMT82LZNT0p0ueK0Y6gvNAm9o= 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 1768464782439246.77922429805415; Thu, 15 Jan 2026 00:13:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgIT1-00030o-Ea; Thu, 15 Jan 2026 03:12:31 -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 1vgIT0-0002xr-1d; Thu, 15 Jan 2026 03:12:30 -0500 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 1vgISy-0006B5-HE; Thu, 15 Jan 2026 03:12:29 -0500 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id D464C80860; Thu, 15 Jan 2026 11:12:26 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:973::1:c]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id PBQgfR0Ar8c0-cwpZoIb6; Thu, 15 Jan 2026 11:12: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=1768464746; bh=yWibqi19WvTNo5ModM1nu+rTjbF5ptLfVCEPC+ZLWJY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=BrwDHAtbF7P6eQSj50sMp+ZcbTdmDyEL87+1vKdQfXEFooucrSJ9gfdRsFjhTssH3 2fS8lvAKG4j3qGcbAMF4dX5J9b8f+JrtyhGm5NnIZE96L6jzClvARGKPOVwnLxBf2e XhEBtPiw9rAEjz6rt92gb4lcG0Q3LDGiaXUOb1DQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.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 v7 4/5] vhost: add vmstate for inflight region with inner buffer Date: Thu, 15 Jan 2026 13:11:07 +0500 Message-Id: <20260115081103.655749-5-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115081103.655749-1-dtalexundeer@yandex-team.ru> References: <20260115081103.655749-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.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, 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: 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: 1768464784819158500 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 Reviewed-by: Stefan Hajnoczi --- hw/virtio/vhost.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 31e9704cdc..7ec2f6fc23 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1916,6 +1916,63 @@ void vhost_get_features_ex(struct vhost_dev *hdev, } } =20 +static bool vhost_inflight_buffer_pre_load(void *opaque, Error **errp) +{ + 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 true; +} + +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() + } +}; + +static bool vhost_inflight_region_post_load(void *opaque, + int version_id, + Error **errp) +{ + struct vhost_inflight *inflight =3D opaque; + + if (inflight->addr =3D=3D NULL) { + error_setg(errp, "inflight buffer subsection has not been loaded"); + return false; + } + + return true; +} + +const VMStateDescription vmstate_vhost_inflight_region =3D { + .name =3D "vhost-inflight-region", + .post_load_errp =3D vhost_inflight_region_post_load, + .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 + } +}; + void vhost_ack_features_ex(struct vhost_dev *hdev, const int *feature_bits, const uint64_t *features) { --=20 2.34.1 From nobody Tue Feb 10 13:19:56 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=1768464787; cv=none; d=zohomail.com; s=zohoarc; b=jWc26CqAKE0c9/9XkGDFajySnxnK3adAyWn6riCe57nlnZQZQ2job90BDBqTkH8JSgu42oJBs0m1EyM1GjPncrOVbuSOMm4HUQvpupD0ZKxzVbtDePkz9mcrvYOwjo0ZMUhWN2+MYq6FKWifnRqshHImNW02Oqy8/++XPuQtcfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768464787; 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=X3OeDLmKjVV7/P6aJCTi/mebxCg/pOWZ8d2ftLLT6Rg=; b=g3n+zM7OMrHSLhAI+UyLN9y3uAd2IeEC6K8uIBPAI8xp1eew8IWsi5jW59YZEaziqTR7AA8LAzCqHwMclJ3iKmzf1FmVSHnAD9Zuss+wLbZLtRQlwWGXDxSIOdM4fPW7jbvVLqcdKwFcmxvqEEHniI0u3vd53SlkjfvjF0Ay8zE= 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 1768464787123729.0796079675449; Thu, 15 Jan 2026 00:13:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgITN-0003jA-QP; Thu, 15 Jan 2026 03:12:55 -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 1vgITF-0003L6-Lu; Thu, 15 Jan 2026 03:12:45 -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 1vgITD-0006Fh-LP; Thu, 15 Jan 2026 03:12:45 -0500 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 241CCC0151; Thu, 15 Jan 2026 11:12:41 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8080:973::1:c]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id PBQgfR0Ar8c0-OgOdefDm; Thu, 15 Jan 2026 11:12: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=1768464760; bh=X3OeDLmKjVV7/P6aJCTi/mebxCg/pOWZ8d2ftLLT6Rg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=EJl5erSoqRp2bfoZbkQIRY1krXauPegVhb7e0mJOS0XUOCftw1Rizq7aV3PXWjG4g sPrbRl/s+hIeZEPGajNBp7hidYTD7H3TkDnj1EhjZNqkrHbYJ/4ua1j0jLrWI9/CPT GbZDw4MXyctD6kCxDHu+f7AdMSc8on0x+iY6QXBU= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.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 v7 5/5] vhost-user-blk: support inter-host inflight migration Date: Thu, 15 Jan 2026 13:11:09 +0500 Message-Id: <20260115081103.655749-6-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115081103.655749-1-dtalexundeer@yandex-team.ru> References: <20260115081103.655749-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: 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: 1768464789001158500 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, with feature flag the vhost-user back-end can immediately stop vrings, so all in-flight requests will be migrated to another host. Signed-off-by: Alexandr Moshkov Reviewed-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 27 +++++++++++++++++++++++++++ include/hw/virtio/vhost-user-blk.h | 1 + include/hw/virtio/vhost.h | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 4d81d2dc34..c151e83677 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -353,6 +353,7 @@ 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) { @@ -568,6 +569,26 @@ 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; + + 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 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 const VMStateDescription vmstate_vhost_user_blk =3D { .name =3D "vhost-user-blk", .minimum_version_id =3D 1, @@ -576,6 +597,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 const Property vhost_user_blk_properties[] =3D { @@ -591,6 +616,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 8158d4673d..1e41a2bcdf 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 #endif diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 08bbb4dfe9..89817bd848 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -554,4 +554,10 @@ static inline int vhost_load_backend_state(struct vhos= t_dev *dev, QEMUFile *f, } #endif =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) + #endif --=20 2.34.1