From nobody Wed Feb 11 02:56:23 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=1768298392; cv=none; d=zohomail.com; s=zohoarc; b=SvSwqOy1wTcsrxrwmJ478lL3n9hlXEU0aZy1PV9XmLgVxH++F8zF2IZN3RNnC2pXjclKomRi0MiIRwS2DzRF79D7dvealwKVJ7LrF3UGVWWNjE/+kNwUbwjVPBzEP0de8fhx43hVQzYip10IwBPpVpyLHlfdvuUwJQLn+MLgnYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768298392; 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=XMMSdWsV7hoMkKSn+5aQ4Vb4bLkyzG3T3BxpqQSyRxY=; b=YEjgstuYTU84BOxLY0usqJE0/dLUqnY41ArXDNIu77ggvnP88MVC1bpcJRT0TrxulboOeZryqHthlb8r6AG5lp+htGt9Z74uH3Z7RIv2pUZ6Tn24Mv2WID+zL95jCL+u6EvkzPR9j7rAP4FN626VIERgoFMIGsLA/JR+sAH55GE= 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 1768298392321431.496916735706; Tue, 13 Jan 2026 01:59:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vfbB1-0003Sh-1o; Tue, 13 Jan 2026 04:59:03 -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 1vfbAz-0003RZ-Cy; Tue, 13 Jan 2026 04:59:01 -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 1vfbAx-0006Fd-SV; Tue, 13 Jan 2026 04:59:01 -0500 Received: from mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net [IPv6:2a02:6b8:c24:fa2:0:640:41ee:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 7F3FB80872; Tue, 13 Jan 2026 12:58:57 +0300 (MSK) Received: from dtalexundeer-nx.yandex.net (unknown [2a02:6bf:803e:400:93c4:8e38:1f90:3c73]) by mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id KwPsag5AAiE0-9RUEQUNk; Tue, 13 Jan 2026 12:58:56 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768298337; bh=XMMSdWsV7hoMkKSn+5aQ4Vb4bLkyzG3T3BxpqQSyRxY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=z6eIawIK1k28FBJ8W8Agi0YANlCVLNm3iHKIJbjS4RXxftRmRdmMmgSoX+qy9iysw N5yvMy3allltUXdm3Bp460Idj02Nfy8aHeYvZ8XlAEzArgvSE/OBzQmnaPJ3y/1AQx /uilIBWONTYZTguXqHOsCRqasvFNUACf3vOKcWrQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-34.sas.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 v6 4/5] vhost: add vmstate for inflight region with inner buffer Date: Tue, 13 Jan 2026 14:58:17 +0500 Message-Id: <20260113095813.134810-5-dtalexundeer@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260113095813.134810-1-dtalexundeer@yandex-team.ru> References: <20260113095813.134810-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_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 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: 1768298394546158500 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 | 57 +++++++++++++++++++++++++++++++++++++++ include/hw/virtio/vhost.h | 6 +++++ 2 files changed, 63 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index c46203eb9c..f655c53b67 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2028,6 +2028,63 @@ 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() + } +}; + +static int 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 -EINVAL; + } + + return 0; +} + +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 + } +}; + 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