From nobody Fri Nov 14 17:02:58 2025 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=1762772394; cv=none; d=zohomail.com; s=zohoarc; b=NJfviyA7ULtLnhe+pNjgILCEOHS/kYzYygAIYwMzejlhhEaOiY21DpzQcv+bS2ktCYnajyiDyl31bGwe0I53Bfw7aQA50VkWnCHtB1ZZ/mOPpXIonKWwm+UoFM7o7qHA5QUBwl7ZNYZ9TdTVY14wQOm/kQ0/SUrhWVOXgLDzQig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762772394; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BBaLzRPC1vSdvTfCEYutHaoyo6yavs9dofrXa1+5uLk=; b=GM1Tq/3CuTZ4uZPlO1ndOCBvHpeccaW15Nev9zNNGtCRVPZgp9EVG180KBxAvMmO6Q9Avmz8F41iBDlDP6YMsjRqOaxhj2LnLfyxQDaCKu9ES0cpVqYetsP9E52877I9/xJu0NtrUsOQMjSNhpSFJCJMKKdk7EQe5uqOA+5+zQ0= 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 1762772394159912.9383795888925; Mon, 10 Nov 2025 02:59:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vIPc2-00077B-27; Mon, 10 Nov 2025 05:59:08 -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 1vIPJf-0007m3-4f for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:07 -0500 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 1vIPJc-0002fH-Cx for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:06 -0500 Received: from mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:94a9:0:640:a3fa:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id BCCFE804D1; Mon, 10 Nov 2025 13:40:02 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8011:f00:439c:fb8b:9c87:386c]) by mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ndKaU81FteA0-B0qRAael; Mon, 10 Nov 2025 13:40:02 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762771202; bh=BBaLzRPC1vSdvTfCEYutHaoyo6yavs9dofrXa1+5uLk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=E+IFO966Zpi5xeei3K4aBMEjwb2P5/holGtyflKYqv7At5JsAJgCeywediuCwhwPz Nr/yND6hR4oA+MlMZkgDHwnJhnASBsbSnHPdeKOuSq7HeXzL+D8hNeHt8LiN8jo1QA b5kwR74N75nrfPpsmZp4OxWI5TUkLtlCKQEZfelU= Authentication-Results: mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Raphael Norwitz , "Michael S. Tsirkin" , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v3 1/3] vmstate: introduce VMSTATE_VBUFFER_UINT64 Date: Mon, 10 Nov 2025 15:39:37 +0500 Message-Id: <20251110103937.1944486-2-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110103937.1944486-1-dtalexundeer@yandex-team.ru> References: <20251110103937.1944486-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 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 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762772397186158500 Content-Type: text/plain; charset="utf-8" This is an analog of VMSTATE_VBUFFER_UINT32 macro, but for uint64 type. Signed-off-by: Alexandr Moshkov Acked-by: Peter Xu --- include/migration/vmstate.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 7f1f1c166a..4c9e212d58 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -707,6 +707,16 @@ extern const VMStateInfo vmstate_info_qlist; .offset =3D offsetof(_state, _field), \ } =20 +#define VMSTATE_VBUFFER_UINT64(_field, _state, _version, _test, _field_siz= e) { \ + .name =3D (stringify(_field)), \ + .version_id =3D (_version), \ + .field_exists =3D (_test), \ + .size_offset =3D vmstate_offset_value(_state, _field_size, uint64_t),\ + .info =3D &vmstate_info_buffer, \ + .flags =3D VMS_VBUFFER | VMS_POINTER, \ + .offset =3D offsetof(_state, _field), \ +} + #define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \ _test, _field_size) { \ .name =3D (stringify(_field)), \ --=20 2.34.1 From nobody Fri Nov 14 17:02:58 2025 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=1762772512; cv=none; d=zohomail.com; s=zohoarc; b=SrDrylrJIio32JhC4/EspT9rW2wjf3GHQQopurdV5IMEsH2H8SnbiWBXa6XPS68SW9nPdqzWd8Xgkthv2fGIB5CbRwZHPAfuT/EAkDlAx7kOBA0iBZACrtX/H/0UjnHllpvuVBTS1R75w1jaQWu/Mi5lNTMgD5RXoSpFAcBSKa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762772512; 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=z8PGdUQGuutXpE5KQ/Zomo9S+sDSgjZY1LOIsQYZrpI=; b=KD+wuVzIfN17zuViw8X1J3NclHiA343VpiQpscRGglZ8YwCD4ZF4Ds72GG4+o0v7QPnoQacm9NBPP5iA76R8JQ0iv3EQ9G25BPjLMaLxx934/n2SgphNnAMwkGe7QrIAuHghbPBFfrCydph+dK7RX3HeQv81In1EyjHkZ46QYaI= 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 1762772512467628.3231516500867; Mon, 10 Nov 2025 03:01:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vIPe7-0007kN-9T; Mon, 10 Nov 2025 06:01:26 -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 1vIPJp-00082U-0t for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:17 -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 1vIPJm-0002r8-Vk for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:16 -0500 Received: from mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:94a9:0:640:a3fa:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id F3942807B6; Mon, 10 Nov 2025 13:40:12 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8011:f00:439c:fb8b:9c87:386c]) by mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ndKaU81FteA0-1OW3t940; Mon, 10 Nov 2025 13:40:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762771212; bh=z8PGdUQGuutXpE5KQ/Zomo9S+sDSgjZY1LOIsQYZrpI=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=w2NGXcSVKRCxROZKqpIwNPDeva+omUqO6nNI2uQiR6AAYU/qxdDNNMGFwzzbZ8r8R IsM2imU3rDNemj5FviFSeWYnSmHea/5yY2IaqzN1mfMrMcYTl0TMwcEZNX/3tMia8z rKDZSv824BIBNgWI00kANVnc8Xj2S4dju7wkmxCk= Authentication-Results: mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Raphael Norwitz , "Michael S. Tsirkin" , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v3 2/3] vhost: add vmstate for inflight region with inner buffer Date: Mon, 10 Nov 2025 15:39:39 +0500 Message-Id: <20251110103937.1944486-3-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110103937.1944486-1-dtalexundeer@yandex-team.ru> References: <20251110103937.1944486-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 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762772514555158500 Content-Type: text/plain; charset="utf-8" Prepare for future inflight region migration for vhost-user-blk. We need to migrate size, queue_size, and inner buffer. So firstly it migrate size and queue_size fields, then allocate memory for = buffer with migrated size, then migrate inner buffer itself. Signed-off-by: Alexandr Moshkov --- hw/virtio/vhost.c | 42 +++++++++++++++++++++++++++++++++++++++ include/hw/virtio/vhost.h | 6 ++++++ 2 files changed, 48 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c46203eb9c..9a746c9861 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2028,6 +2028,48 @@ const VMStateDescription vmstate_backend_transfer_vh= ost_inflight =3D { } }; =20 +static int vhost_inflight_buffer_pre_load(void *opaque, Error **errp) +{ + info_report("vhost_inflight_region_buffer_pre_load"); + struct vhost_inflight *inflight =3D opaque; + + int fd =3D -1; + void *addr =3D qemu_memfd_alloc("vhost-inflight", inflight->size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEA= L, + &fd, errp); + if (*errp) { + return -ENOMEM; + } + + inflight->offset =3D 0; + inflight->addr =3D addr; + inflight->fd =3D fd; + + return 0; +} + +const VMStateDescription vmstate_vhost_inflight_region_buffer =3D { + .name =3D "vhost-inflight-region/buffer", + .pre_load_errp =3D vhost_inflight_buffer_pre_load, + .fields =3D (const VMStateField[]) { + VMSTATE_VBUFFER_UINT64(addr, struct vhost_inflight, 0, NULL, size), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_vhost_inflight_region =3D { + .name =3D "vhost-inflight-region", + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(size, struct vhost_inflight), + VMSTATE_UINT16(queue_size, struct vhost_inflight), + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_vhost_inflight_region_buffer, + NULL + } +}; + const VMStateDescription vmstate_vhost_virtqueue =3D { .name =3D "vhost-virtqueue", .fields =3D (const VMStateField[]) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 13ca2c319f..dd552de91f 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -596,6 +596,12 @@ extern const VMStateDescription vmstate_backend_transf= er_vhost_inflight; vmstate_backend_transfer_vhost_inflight, \ struct vhost_inflight) =20 +extern const VMStateDescription vmstate_vhost_inflight_region; +#define VMSTATE_VHOST_INFLIGHT_REGION(_field, _state) \ + VMSTATE_STRUCT_POINTER(_field, _state, \ + vmstate_vhost_inflight_region, \ + struct vhost_inflight) + extern const VMStateDescription vmstate_vhost_dev; #define VMSTATE_BACKEND_TRANSFER_VHOST(_field, _state) \ VMSTATE_STRUCT(_field, _state, 0, vmstate_vhost_dev, struct vhost_dev) --=20 2.34.1 From nobody Fri Nov 14 17:02:58 2025 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=1762772576; cv=none; d=zohomail.com; s=zohoarc; b=LyJHqFVyRsHvnn87IDqZo6OvCTvktmERodUDGEx0nKWGglqu7jAkzgnmTiGPyQNTY+LJQ3ViM8kwLuguW/Oec/PX43nVC8ZwOLd/xrbo0iHGda3LFrM5Svr2jw4uxFzwUe0z1urvkfodNA2x3pHMkGNpK4yRrx2YRaDJEk2cBg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762772576; 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=WWaIfGLxmB79niuepFPqr1PNMfJA3+W6jLKuoFumxpc=; b=JEouezwJrOJBYPhRHYScIt1y6GQ+emgrGByxFiWonU45DY/AuZQN80CCap7fUqjGzE1eDA8SZBXlypgUHKtal5iEWA7lxZFS+5jQ9ksv45DyNRo1uvf1GhwbP7likZABPsg9MA00ehcCK5zsrOVi+H38sq9zFY1eehwevRGHaF4= 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 1762772576523364.77485496138434; Mon, 10 Nov 2025 03:02:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vIPew-0000EI-Cp; Mon, 10 Nov 2025 06:02:06 -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 1vIPJz-0008CQ-1Q for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:27 -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 1vIPJx-0002tN-7e for qemu-devel@nongnu.org; Mon, 10 Nov 2025 05:40:26 -0500 Received: from mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:94a9:0:640:a3fa:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id CDFEE804D1; Mon, 10 Nov 2025 13:40:23 +0300 (MSK) Received: from dtalexundeer-nx.yandex-team.ru (unknown [2a02:6bf:8011:f00:439c:fb8b:9c87:386c]) by mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id ndKaU81FteA0-6OhXgPv0; Mon, 10 Nov 2025 13:40:23 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762771223; bh=WWaIfGLxmB79niuepFPqr1PNMfJA3+W6jLKuoFumxpc=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=S/niCiMfN0h0RRgOtjHfznHYgAMjXsj/yZKYlFzb7tFcRQvwvyCwZ0hjgGD7C03di Pm3OJ9/abhfm24dYRsVXZ/MUTs6VF15INQLdOd2rVZR0wghFKynZc5J6tmvBMXHNL9 JK2BTolwzAiEzGLbL4bmOsG5kvsJuPwFC/v1oRbQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-68.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Alexandr Moshkov To: qemu-devel@nongnu.org Cc: Raphael Norwitz , "Michael S. Tsirkin" , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Peter Xu , Fabiano Rosas , Eric Blake , Markus Armbruster , Alexandr Moshkov Subject: [PATCH v3 3/3] vhost-user-blk: support inter-host inflight migration Date: Mon, 10 Nov 2025 15:39:41 +0500 Message-Id: <20251110103937.1944486-4-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251110103937.1944486-1-dtalexundeer@yandex-team.ru> References: <20251110103937.1944486-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 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762772579206158500 Content-Type: text/plain; charset="utf-8" During inter-host migration, waiting for disk requests to be drained in the vhost-user backend can incur significant downtime. This can be avoided if QEMU migrates the inflight region in vhost-user-blk. Thus, during the qemu migration, the vhost-user backend can cancel all inflight requests and then, after migration, they will be executed on another host. In vhost_user_blk_stop() on incoming inter-host migration make force_stop =3D true, so GET_VRING_BASE will not be executed. Signed-off-by: Alexandr Moshkov --- hw/block/vhost-user-blk.c | 29 +++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-blk.h | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a8fd90480a..2d9b398de6 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -139,6 +139,14 @@ 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; + + return s->skip_get_vring_base_inflight_migration && + !migrate_local_vhost_user_blk(); +} + static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); @@ -242,6 +250,11 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 + if (vhost_user_blk_inflight_needed(s) && + runstate_check(RUN_STATE_FINISH_MIGRATE)) { + force_stop =3D true; + } + s->dev.backend_transfer =3D s->dev.backend_transfer || (runstate_check(RUN_STATE_FINISH_MIGRATE) && migrate_local_vhost_user_blk()); @@ -656,6 +669,16 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Virt= IODevice *vdev) return &s->dev; } =20 +static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { + .name =3D "vhost-user-blk/inflight", + .version_id =3D 1, + .needed =3D vhost_user_blk_inflight_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), + VMSTATE_END_OF_LIST() + }, +}; + static bool vhost_user_blk_pre_incoming(void *opaque, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(opaque); @@ -678,6 +701,10 @@ static const VMStateDescription vmstate_vhost_user_blk= =3D { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_vhost_user_blk_inflight, + NULL + } }; =20 static bool vhost_user_needed(void *opaque) @@ -751,6 +778,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("skip-get-vring-base-inflight-migration", VHostUserBl= k, + skip_get_vring_base_inflight_migration, false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index b06f55fd6f..859fb96956 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 skip_get_vring_base_inflight_migration; =20 bool incoming_backend; }; --=20 2.34.1