From nobody Fri Nov 14 18:23:11 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=1760615483; cv=none; d=zohomail.com; s=zohoarc; b=mNi5gNlWa/qa3SEecD5fQNyWd6NYpGbPKMhRqC0iajGomJ10SFdgpwwd5nvB2e3Fs5aF/yhOCgBeltU+5IQzzK68ZJRs9wj+zGZMYFFJpb2A5B0hrF5ASVYSGzt7n3BJv0/jJKXweQtB0w/vTkpwhSDpzAEtPCCIthv2lkSINps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615483; 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=CfhYPdDYFOJ4e5JUBvq3LuUdv3/kmqX/+3b/YXayICo=; b=ECrfOCD/9WUDsHvt4IqpLMcGco81vUrKnL6uMUd9a615MmuksIS7JsVr8WsmZE9Z9w/aqYCMulhFFDMZYsmcWPhz/WzY9zhjW4+9LgS0hy5QH/BOoellvYxWHM6AtTSDnzgxQE0VNWq7QT/hHepckxLdCB4duqFDiYxpioGsmH0= 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 1760615483623489.2688640393143; Thu, 16 Oct 2025 04:51:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNV-0007No-OO; Thu, 16 Oct 2025 07:42:42 -0400 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 1v9MMa-000759-J1; Thu, 16 Oct 2025 07:41:44 -0400 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 1v9MMS-0003T4-BH; Thu, 16 Oct 2025 07:41:42 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id F15A2C01B6; Thu, 16 Oct 2025 14:41:23 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-miagcnfi; Thu, 16 Oct 2025 14:41: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=1760614883; bh=CfhYPdDYFOJ4e5JUBvq3LuUdv3/kmqX/+3b/YXayICo=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=zjmQvNXa10TTR0yKPhfPwBcD6OSuEK6RTnsIkM5zrcCWo+iGH/T1SRKko4ClU5UAy PhSsmLH9FTGaUx0giQgBMfXytg87HLUtxqhuSiNsm/D4pAbLuQkLQMJfMn7TA7m/TN RcK7xepRFCUePAuTdF+e0UDj/xgOji2JJJV8yK7Y= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 01/25] vhost: store busyloop_timeout into struct vhost_dev Date: Thu, 16 Oct 2025 14:40:38 +0300 Message-ID: <20251016114104.1384675-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615490800158500 Content-Type: text/plain; charset="utf-8" We'll split vhost_dev_init() into _init() and _connect(), to be able to postpone communication with backend, to support backend-transfer migration of vhost-user-blk in future commit. So, instead of passing it through parameters, store it in vhost_dev structure. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/virtio/vhost.c | 11 +++++------ include/hw/virtio/vhost.h | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7ba90c24db..9fc6e7ba65 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1501,8 +1501,7 @@ static void vhost_virtqueue_error_notifier(EventNotif= ier *n) } =20 static int vhost_virtqueue_init(struct vhost_dev *dev, - struct vhost_virtqueue *vq, int n, - bool busyloop_timeout) + struct vhost_virtqueue *vq, int n) { int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, n); struct vhost_vring_file file =3D { @@ -1539,8 +1538,8 @@ static int vhost_virtqueue_init(struct vhost_dev *dev, vhost_virtqueue_error_notifier); } =20 - if (busyloop_timeout) { - r =3D vhost_virtqueue_set_busyloop_timeout(dev, n, busyloop_timeou= t); + if (dev->busyloop_timeout) { + r =3D vhost_virtqueue_set_busyloop_timeout(dev, n, dev->busyloop_t= imeout); if (r < 0) { VHOST_OPS_DEBUG(r, "Failed to set busyloop timeout"); goto fail_err; @@ -1628,6 +1627,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, =20 hdev->vdev =3D NULL; hdev->migration_blocker =3D NULL; + hdev->busyloop_timeout =3D busyloop_timeout; =20 r =3D vhost_set_backend_type(hdev, backend_type); assert(r >=3D 0); @@ -1650,8 +1650,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, } =20 for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { - r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i, - busyloop_timeout); + r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i= ); if (r < 0) { error_setg_errno(errp, -r, "Failed to initialize virtqueue %d"= , i); goto fail; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 1ba1af1d86..f1a7e7b971 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -105,6 +105,7 @@ struct vhost_dev { VIRTIO_DECLARE_FEATURES(_features); VIRTIO_DECLARE_FEATURES(acked_features); =20 + uint32_t busyloop_timeout; uint64_t max_queues; uint64_t backend_cap; /* @started: is the vhost device started? */ --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760614986; cv=none; d=zohomail.com; s=zohoarc; b=Ig8pI6ZV2VGjxeRCuK60+8RQd0CQujR/yzPnFbls8wYHJpRIeS2NNiURa41wFMlzazyugMW7CRnGHVV4loDEF4RsW+WhkFxZNRRzr8mYmrSSR3KJ4SW29u3E/zI+6hnhc3WFsqP8ACWcUwBnoqaC3dljXqQAi1CxfsQnm3TClns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760614986; 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=/c9vHUY6t9wfX6BiEAXJfYRSmsDMfiIQQ+vKZjiVzb0=; b=PTcX9sQbDtrcEz47q9UC/VnkGr4GtAeIAxh1LMXMxZiVhp9f6ttfBQV2njVNbk/X+u3ClWwLxOld7rktWkXmmMHJQf1j5kXAMvJBO2YqDP+z/gPc6kTFHMygGulp8d0cqmDgSM/9jX1u0vD/NvteDuqpA7ecWNiwSETnFXXkrUc= 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 1760614985653328.63891526438783; Thu, 16 Oct 2025 04:43:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MMi-00076J-GR; Thu, 16 Oct 2025 07:41:53 -0400 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 1v9MMU-00074M-5Q; Thu, 16 Oct 2025 07:41:38 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMP-0003T5-3e; Thu, 16 Oct 2025 07:41:37 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id A7E4CC01BE; Thu, 16 Oct 2025 14:41:24 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-BlswLnpY; Thu, 16 Oct 2025 14:41:24 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614884; bh=/c9vHUY6t9wfX6BiEAXJfYRSmsDMfiIQQ+vKZjiVzb0=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=MafyoRUcLEbYcdoJ+sEz3cvhWuIXSu+2B6TXBp1MEhbJBG4eiapp4lN1KGFgoNsxo 4LT5CrmsXyJ02ntsF1j6o/pEJd5VbnFpUMm6+2kvrCUZskSlnumNwLD3mibuQM4jTm J1heqg+91rRWAn61Xw5ilmB5TxQ/EEOetpeWVZl4= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 02/25] vhost: reorder logic in vhost_dev_init() Date: Thu, 16 Oct 2025 14:40:39 +0300 Message-ID: <20251016114104.1384675-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760614990143158500 Content-Type: text/plain; charset="utf-8" We are going to split vhost_dev_init() so that the first part will do early initialization of QEMU structures, but don't communicate with backend, and the second part will do backend communication. We need this for future support for backend-transfer migration support for vhost-user-blk (backend will not be available in the early initialization point). With this commit, we simply reorder the logic in vhost_dev_init() in accordance with idea of further split. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/virtio/vhost.c | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9fc6e7ba65..551d1687fc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1637,26 +1637,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, goto fail; } =20 - r =3D hdev->vhost_ops->vhost_set_owner(hdev); - if (r < 0) { - error_setg_errno(errp, -r, "vhost_set_owner failed"); - goto fail; - } - - r =3D vhost_dev_init_features(hdev); - if (r < 0) { - error_setg_errno(errp, -r, "vhost_init_features failed"); - goto fail; - } - - for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { - r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i= ); - if (r < 0) { - error_setg_errno(errp, -r, "Failed to initialize virtqueue %d"= , i); - goto fail; - } - } - hdev->memory_listener =3D (MemoryListener) { .name =3D "vhost", .begin =3D vhost_begin, @@ -1677,6 +1657,36 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, .region_del =3D vhost_iommu_region_del, }; =20 + hdev->mem =3D g_malloc0(offsetof(struct vhost_memory, regions)); + hdev->n_mem_sections =3D 0; + hdev->mem_sections =3D NULL; + hdev->log =3D NULL; + hdev->log_size =3D 0; + hdev->log_enabled =3D false; + hdev->started =3D false; + memory_listener_register(&hdev->memory_listener, &address_space_memory= ); + QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); + + r =3D hdev->vhost_ops->vhost_set_owner(hdev); + if (r < 0) { + error_setg_errno(errp, -r, "vhost_set_owner failed"); + goto fail; + } + + r =3D vhost_dev_init_features(hdev); + if (r < 0) { + error_setg_errno(errp, -r, "vhost_init_features failed"); + goto fail; + } + + for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { + r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i= ); + if (r < 0) { + error_setg_errno(errp, -r, "Failed to initialize virtqueue %d"= , i); + goto fail; + } + } + if (hdev->migration_blocker =3D=3D NULL) { if (!vhost_dev_has_feature_ex(hdev, VHOST_F_LOG_ALL)) { error_setg(&hdev->migration_blocker, @@ -1694,16 +1704,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, } } =20 - hdev->mem =3D g_malloc0(offsetof(struct vhost_memory, regions)); - hdev->n_mem_sections =3D 0; - hdev->mem_sections =3D NULL; - hdev->log =3D NULL; - hdev->log_size =3D 0; - hdev->log_enabled =3D false; - hdev->started =3D false; - memory_listener_register(&hdev->memory_listener, &address_space_memory= ); - QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); - if (!check_memslots(hdev, errp)) { r =3D -EINVAL; goto fail; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615262; cv=none; d=zohomail.com; s=zohoarc; b=RDta960D9Af036W3gR2f+pojaSqzWXBxfc4CsB6nIbv4bOmPLQ3PnhOzzK2GzHyeYYbE/b8O6jJisqV0puCydJoiadbyGq0EtHFn23PiAEoDMAaLuX+6pehIKae5IwXgk6HVwDwi+sTIOS9bDFqawQLOo/fvmE6Fmmcju311RMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615262; 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=oUrqGQn8nA2eMNAmO6zdAoCyWwMbaYpJ91T595m/zmU=; b=bKnUe+PQJiYbC9AwHmCAD3puB23PcFgTVvMAbVp7kSkmEsxQgNDbhES/C7+EYYvAcVNypcFnTyuDz4+dGKPM3W7nXkSeczBpH+T1cZ/BN1Rt13afdoCDETS1pd7ztckeEX81op6BX6wTRx4tnPrlgCXXZb26iihfhs6ttozG4lo= 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 1760615262847102.83079783435892; Thu, 16 Oct 2025 04:47:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MMp-00077q-DZ; Thu, 16 Oct 2025 07:42:00 -0400 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 1v9MMW-00074e-T6; Thu, 16 Oct 2025 07:41:41 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMO-0003T9-4R; Thu, 16 Oct 2025 07:41:38 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 577A9C00CF; Thu, 16 Oct 2025 14:41:25 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-qM11FZnG; Thu, 16 Oct 2025 14:41:24 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614884; bh=oUrqGQn8nA2eMNAmO6zdAoCyWwMbaYpJ91T595m/zmU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=COUKJ3TvjuN+AO0dq37aSPxwgnWuDHk4szXMPRYQuiLLeoatWXNjg3E1g7JVWOFQT dhHi5V+/oPYun/F/yQ89Nnht2Ul0Hx+6Ke+nqlGL2aFw9y7oOYzOrkgqkOi+kdvEBY NtbgvB6pBxOQ4GHbhWsVnBzmSMB+K2r59fMn5tKY= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 03/25] vhost: rework vhost_virtqueue_init() Date: Thu, 16 Oct 2025 14:40:40 +0300 Message-ID: <20251016114104.1384675-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615265866158500 Content-Type: text/plain; charset="utf-8" We are going to split vhost_dev_init() so that the first part will do early initialization of QEMU structures, but don't communicate with backend, and the second part will do backend communication. We need this for future support for backend-transfer migration support for vhost-user-blk (backend will not be available in the early initialization point). With this commit, let's split vhost_virtqueue_init(). The whole function is mostly about configuring the backend, so this logic will be postponed until backend become available. The only thing to keep in early initialization is attaching vhost_dev structure. Let's simply move it to vhost_dev_init(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/virtio/vhost.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 551d1687fc..1998663461 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1500,9 +1500,9 @@ static void vhost_virtqueue_error_notifier(EventNotif= ier *n) } } =20 -static int vhost_virtqueue_init(struct vhost_dev *dev, - struct vhost_virtqueue *vq, int n) +static int vhost_virtqueue_connect(struct vhost_virtqueue *vq, int n) { + struct vhost_dev *dev =3D vq->dev; int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, n); struct vhost_vring_file file =3D { .index =3D vhost_vq_index, @@ -1519,8 +1519,6 @@ static int vhost_virtqueue_init(struct vhost_dev *dev, goto fail_call; } =20 - vq->dev =3D dev; - if (dev->vhost_ops->vhost_set_vring_err) { r =3D event_notifier_init(&vq->error_notifier, 0); if (r < 0) { @@ -1629,6 +1627,10 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, hdev->migration_blocker =3D NULL; hdev->busyloop_timeout =3D busyloop_timeout; =20 + for (i =3D 0; i < hdev->nvqs; ++i) { + hdev->vqs[i].dev =3D hdev; + } + r =3D vhost_set_backend_type(hdev, backend_type); assert(r >=3D 0); =20 @@ -1680,7 +1682,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, } =20 for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { - r =3D vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i= ); + r =3D vhost_virtqueue_connect(hdev->vqs + i, hdev->vq_index + i); if (r < 0) { error_setg_errno(errp, -r, "Failed to initialize virtqueue %d"= , i); goto fail; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615009; cv=none; d=zohomail.com; s=zohoarc; b=jSgBcfVTzgecdUMqOMGDubszY4nO7CjszS4XLAk5T5SXloZb4Flu7x2ZHYrSQP7/JdAT9yDYMT6JxWPrT2qPOf+q9PC/6kNc8HjH7Cxgs85fpPByvAcuNWBnZhIk4MTGadOnwlX18YU7FdxcJP2L1wmjW0g2bXbx2KoKX6M1Or8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615009; 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=1XLVUveyIaEDAIm+7CqDo71QUDU3u/IS07Ut6dYodbI=; b=GVRHgOwx13QAZiXVsMTTqoTKes7sPgk0tWQKzinkI9goMqlJWmqH9Y6wCAx9WdT8lpFHpAWdoPWbvL14cUwW67EQFsg3illBaPXW8FfK/hoiOcocgiZ5aPfDTS6lPBgBlGm4RvSIVzh7sV1+eWBCF2fyokMvVsYQNXxwqTdhk+E= 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 1760615008693876.4952516774783; Thu, 16 Oct 2025 04:43:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNT-0007MV-P4; Thu, 16 Oct 2025 07:42:40 -0400 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 1v9MMa-000756-Ip; Thu, 16 Oct 2025 07:41:45 -0400 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 1v9MMP-0003TH-4H; Thu, 16 Oct 2025 07:41:41 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 5F8F4C01C4; Thu, 16 Oct 2025 14:41:27 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-YwdwMwTh; Thu, 16 Oct 2025 14:41: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=1760614886; bh=1XLVUveyIaEDAIm+7CqDo71QUDU3u/IS07Ut6dYodbI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Z+mybsH6zZVmhLLxSCPAlHvzL9hbLIu9a7IErhUe8ADqmNJqrOudDLiV/pojAGX9l hhgVwHqTsRX00/475BHRumbxPXjaGwNx0i5GMnIc5OD17BFvh8qi59WT3bsHup1/zV X9aWv3gJfd3FJkqqv58tdfUD3jmisC5UR0a6L7/M= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com, "Gonglei (Arei)" , Zhenwei Pi , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Hajnoczi , mzamazal@redhat.com (reviewer:vhost-user-scmi), virtio-fs@lists.linux.dev (open list:virtiofs) Subject: [PATCH v2 04/25] vhost: add connect parameter to vhost_dev_init() Date: Thu, 16 Oct 2025 14:40:41 +0300 Message-ID: <20251016114104.1384675-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615011565158500 Content-Type: text/plain; charset="utf-8" We are going to split vhost_dev_init() so that the first part will do early initialization of QEMU structures, but don't communicate with backend, and the second part will do backend communication. We need this for future support for backend-transfer migration support for vhost-user-blk (backend will not be available in the early initialization point). With this commit we introduce boolean parameter for vhost_dev_init(), so callers may chose, do they want "init + connect" (which is current behavior, so all callers pass true), or caller may want "only init", and call vhost_dev_connect() later. vhost_dev_connect(), as well as support for connect=3Dfalse will be added in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- backends/cryptodev-vhost.c | 2 +- backends/vhost-user.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/net/vhost_net.c | 2 +- hw/scsi/vhost-scsi.c | 2 +- hw/scsi/vhost-user-scsi.c | 2 +- hw/virtio/vdpa-dev.c | 3 ++- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-scmi.c | 2 +- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock.c | 2 +- hw/virtio/vhost.c | 11 ++++++++++- include/hw/virtio/vhost-backend.h | 2 ++ include/hw/virtio/vhost.h | 3 ++- 15 files changed, 27 insertions(+), 14 deletions(-) diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index c6069f4e5b..b4dafb4062 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -66,7 +66,7 @@ cryptodev_vhost_init( crypto->dev.vq_index =3D crypto->cc->queue_index * crypto->dev.nvqs; =20 r =3D vhost_dev_init(&crypto->dev, options->opaque, options->backend_t= ype, 0, - &local_err); + true, &local_err); if (r < 0) { error_report_err(local_err); goto fail; diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 42845329e7..e65ba7b648 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -37,7 +37,7 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODe= vice *vdev, b->dev.vqs =3D g_new0(struct vhost_virtqueue, nvqs); =20 ret =3D vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, - errp); + true, errp); if (ret < 0) { return -1; } diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a5daed4346..a92426f18c 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -365,7 +365,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) =20 s->vhost_user.supports_config =3D true; ret =3D vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, - errp); + true, errp); if (ret < 0) { return ret; } diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 323d117735..c4526974fb 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -274,7 +274,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) =20 r =3D vhost_dev_init(&net->dev, options->opaque, options->backend_type, options->busyloop_timeout, - &local_err); + true, &local_err); if (r < 0) { error_report_err(local_err); goto fail; diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index d694a25fe2..d187c705d8 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -278,7 +278,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error = **errp) vsc->dev.vq_index =3D 0; =20 ret =3D vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd, - VHOST_BACKEND_TYPE_KERNEL, 0, errp); + VHOST_BACKEND_TYPE_KERNEL, 0, true, errp); if (ret < 0) { /* * vhost_dev_init calls vhost_dev_cleanup on error, which closes diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 0c80a271d8..e121f2e259 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -161,7 +161,7 @@ static int vhost_user_scsi_connect(DeviceState *dev, Er= ror **errp) vsc->dev.vq_index =3D 0; =20 ret =3D vhost_dev_init(&vsc->dev, &s->vhost_user, VHOST_BACKEND_TYPE_U= SER, 0, - errp); + true, errp); if (ret < 0) { return ret; } diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index e1a2ff433d..b6b4ee7d38 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -116,7 +116,8 @@ static void vhost_vdpa_device_realize(DeviceState *dev,= Error **errp) v->vdpa.shared->device_fd =3D v->vhostfd; v->vdpa.shared->iova_range =3D iova_range; =20 - ret =3D vhost_dev_init(&v->dev, &v->vdpa, VHOST_BACKEND_TYPE_VDPA, 0, = NULL); + ret =3D vhost_dev_init(&v->dev, &v->vdpa, VHOST_BACKEND_TYPE_VDPA, 0, = true, + NULL); if (ret < 0) { error_setg(errp, "vhost-vdpa-device: vhost initialization failed: = %s", strerror(-ret)); diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index cf311c3bfc..0768231a88 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -334,7 +334,7 @@ static void vub_device_realize(DeviceState *dev, Error = **errp) =20 /* connect to backend */ ret =3D vhost_dev_init(&vub->vhost_dev, &vub->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); + VHOST_BACKEND_TYPE_USER, 0, true, errp); =20 if (ret < 0) { do_vhost_user_cleanup(vdev, vub); diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e77c69eb12..2a8eead90b 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -256,7 +256,7 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) fs->vhost_dev.nvqs =3D 1 + fs->conf.num_request_queues; fs->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, fs->vhost_dev.nvq= s); ret =3D vhost_dev_init(&fs->vhost_dev, &fs->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); + VHOST_BACKEND_TYPE_USER, 0, true, errp); if (ret < 0) { goto err_virtio; } diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index f9264c4374..40e567c18a 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -253,7 +253,7 @@ static void vu_scmi_device_realize(DeviceState *dev, Er= ror **errp) scmi->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, scmi->vhost_dev= .nvqs); =20 ret =3D vhost_dev_init(&scmi->vhost_dev, &scmi->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); + VHOST_BACKEND_TYPE_USER, 0, true, errp); if (ret < 0) { error_setg_errno(errp, -ret, "vhost-user-scmi: vhost_dev_init() failed"); diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 993c287348..b630af0fe7 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -115,7 +115,7 @@ static void vuv_device_realize(DeviceState *dev, Error = **errp) vhost_dev_set_config_notifier(&vvc->vhost_dev, &vsock_ops); =20 ret =3D vhost_dev_init(&vvc->vhost_dev, &vsock->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); + VHOST_BACKEND_TYPE_USER, 0, true, errp); if (ret < 0) { goto err_virtio; } diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 107d88babe..3a4b2d924d 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -166,7 +166,7 @@ static void vhost_vsock_device_realize(DeviceState *dev= , Error **errp) vhost_vsock_common_realize(vdev); =20 ret =3D vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, - VHOST_BACKEND_TYPE_KERNEL, 0, errp); + VHOST_BACKEND_TYPE_KERNEL, 0, true, errp); if (ret < 0) { /* * vhostfd is closed by vhost_dev_cleanup, which is called diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1998663461..f733e98b4a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1617,7 +1617,7 @@ static bool check_memslots(struct vhost_dev *hdev, Er= ror **errp) =20 int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, - Error **errp) + bool connect, Error **errp) { int i, r, n_initialized_vqs =3D 0; =20 @@ -1634,6 +1634,15 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, r =3D vhost_set_backend_type(hdev, backend_type); assert(r >=3D 0); =20 + /* + * Postponed connect only supported for devices with + * .vhost_backend_connect handler + */ + assert(connect || hdev->vhost_ops->vhost_backend_connect); + + /* TDDO: support connect=3Dfalse */ + assert(connect); + r =3D hdev->vhost_ops->vhost_backend_init(hdev, opaque, errp); if (r < 0) { goto fail; diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index ff94fa1734..d3f055f95e 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -53,6 +53,7 @@ struct vhost_virtqueue; =20 typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque, Error **errp); +typedef int (*vhost_backend_connect)(struct vhost_dev *dev, Error **errp); typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev); =20 @@ -167,6 +168,7 @@ typedef int (*vhost_check_device_state_op)(struct vhost= _dev *dev, Error **errp); typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; + vhost_backend_connect vhost_backend_connect; vhost_backend_cleanup vhost_backend_cleanup; vhost_backend_memslots_limit vhost_backend_memslots_limit; vhost_backend_no_private_memslots_op vhost_backend_no_private_memslots; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index f1a7e7b971..74ed24232e 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -155,7 +155,8 @@ struct vhost_net { */ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, - uint32_t busyloop_timeout, Error **errp); + uint32_t busyloop_timeout, + bool connect, Error **errp); =20 /** * vhost_dev_cleanup() - tear down and cleanup vhost interface --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615512; cv=none; d=zohomail.com; s=zohoarc; b=AKuJWcj/S0ZSVaUvGE8NHgCNSccqJmCTI0ZiP7cfKZUlOKzJShsuHuy95+xuDvZlPkdyLfp14jOrFjsELCEP5x4pVVs3E0HwIth+cYg57f68p4JyerzydQsSq1vGZ8b0LK1iPr1XuVh99ds6Nq0FKS1MXJcsTfVZ/F1mLF5SSLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615512; 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=NCBQBj1KLYl9rxemiXXzJo8O03ptUskg5oqIPqd6fMU=; b=IU+Fa0DOmvCVsl/Dtr97+zOlYH9SSKC7DXEEPo46xEYHi4u8VjV3HwrB75Gymqp/VD/5wHHhfEkV/657PWygVmFUqpq6zLhhvnxkTLTDNaZsjVQJfD97pDb8f1SvGQqvDJ60XpC2QLbQq3zKlMj/gCRxFp7rAW37DQk5piqfDPw= 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 1760615512861882.4345099737116; Thu, 16 Oct 2025 04:51:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MMx-0007A7-Ax; Thu, 16 Oct 2025 07:42:07 -0400 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 1v9MMb-00075S-Qi; Thu, 16 Oct 2025 07:41:46 -0400 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 1v9MMQ-0003TM-DP; Thu, 16 Oct 2025 07:41:44 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 2093FC01C6; Thu, 16 Oct 2025 14:41:28 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-tJ9HppKJ; Thu, 16 Oct 2025 14:41:27 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614887; bh=NCBQBj1KLYl9rxemiXXzJo8O03ptUskg5oqIPqd6fMU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Gm2tYnLEYpgakuaZolY3N0OZpoTs2w0M/6wY6x3J5iIfQCOetsskp7V7cil59D4yn 8jtLr5v7oO6E05J8MOsAt32f5t8RcZv9TnpjJl4JqUIq0P/PpPwqoLAUhFzCJaolDU KBGFI1aAss3Am78ApraFMhS+xqMpo+e4WX3wkjI4= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 05/25] vhost: split vhost_dev_connect() out of vhost_dev_init() Date: Thu, 16 Oct 2025 14:40:42 +0300 Message-ID: <20251016114104.1384675-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615514799158500 Content-Type: text/plain; charset="utf-8" Split vhost_dev_init() so that the first part will do early initialization of QEMU structures, but don't communicate with backend, and the second part will do backend communication. We need this for future support for backend-transfer migration support for vhost-user-blk (backend will not be available in the early initialization point). Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/virtio/vhost.c | 27 +++++++++++++++++++++------ include/hw/virtio/vhost.h | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f733e98b4a..09d00e4d98 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1619,7 +1619,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, VhostBackendType backend_type, uint32_t busyloop_timeou= t, bool connect, Error **errp) { - int i, r, n_initialized_vqs =3D 0; + int i, r; =20 trace_vhost_dev_init_in(hdev); =20 @@ -1640,9 +1640,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, */ assert(connect || hdev->vhost_ops->vhost_backend_connect); =20 - /* TDDO: support connect=3Dfalse */ - assert(connect); - r =3D hdev->vhost_ops->vhost_backend_init(hdev, opaque, errp); if (r < 0) { goto fail; @@ -1678,6 +1675,26 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opa= que, memory_listener_register(&hdev->memory_listener, &address_space_memory= ); QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); =20 + trace_vhost_dev_init_out(hdev); + + return connect ? vhost_dev_connect(hdev, errp) : 0; + +fail: + vhost_dev_cleanup(hdev); + return r; +} + +int vhost_dev_connect(struct vhost_dev *hdev, Error **errp) +{ + int i, r, n_initialized_vqs =3D 0; + + if (hdev->vhost_ops->vhost_backend_connect) { + r =3D hdev->vhost_ops->vhost_backend_connect(hdev, errp); + if (r < 0) { + goto fail; + } + } + r =3D hdev->vhost_ops->vhost_set_owner(hdev); if (r < 0) { error_setg_errno(errp, -r, "vhost_set_owner failed"); @@ -1720,8 +1737,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, goto fail; } =20 - trace_vhost_dev_init_out(hdev); - return 0; =20 fail: diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 74ed24232e..af46d4b5f2 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -158,6 +158,8 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, uint32_t busyloop_timeout, bool connect, Error **errp); =20 +int vhost_dev_connect(struct vhost_dev *hdev, Error **errp); + /** * vhost_dev_cleanup() - tear down and cleanup vhost interface * @hdev: the common vhost_dev structure --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760614984; cv=none; d=zohomail.com; s=zohoarc; b=Xtc+oF2PSnnTkKKjrglwwkD4QysMvuyvtXMpS3BEXWvjyV+MMvrkH7hBU8Qx0gxsYwcwuRCTMhdC/tj/JE/Ul0GyTwCHn1kV5Lh5m95hAzoZUlU1Ok3OnLkw5FuMXSFoAgYi5qUQPz+e1tk2aOHzb7I2nISaUHOOCgm1Rq+3OhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760614984; 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=4rS5GwKjIvlDX1eshLc4ZTaaWpM9BPePyTr5g8fR2nE=; b=NlR2rw+GPuWhZUeq/FBdkb8KGulNGi3+767LeVwA2SsYuaF5Oeu3C4nHxj/h9Y8/5lwEHy7+NYWM1F2HHa5XPLwv6/RM0ZUdPmMrc6Kg6DGEPGrSBMYzWNh2xSJRWF9OgJS4RogpVd3aBMjlHXhD7ZyUdIIW7+INjQhPYe8eWGk= 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 1760614983640611.9199695390128; Thu, 16 Oct 2025 04:43:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MMr-00078Q-MW; Thu, 16 Oct 2025 07:42:03 -0400 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 1v9MMX-00074f-OK; Thu, 16 Oct 2025 07:41:41 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMQ-0003Ta-16; Thu, 16 Oct 2025 07:41:38 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id E6E48C01C7; Thu, 16 Oct 2025 14:41:28 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-ehkGRQYn; Thu, 16 Oct 2025 14:41:28 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614888; bh=4rS5GwKjIvlDX1eshLc4ZTaaWpM9BPePyTr5g8fR2nE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=ZxvaYQe2l/ECS6bCdiFwdBkT1icqfbUOvLZwVEcEU6vm/SJx/gkhP6jwRW1R3fmpl wy5/3mn/UKNBgILAGNDD40PvPZ7JX5vcrOtoSx8Cu6RsPBfFgVZPPd4+QKWJAhrc1X Cj3UYvBKncrxqW2jWUrbqABgM24rp+Wk1FGXMuQU= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 06/25] vhost-user: support connect api Date: Thu, 16 Oct 2025 14:40:43 +0300 Message-ID: <20251016114104.1384675-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760614990137154100 Content-Type: text/plain; charset="utf-8" Memory allocation and connecting of structures remain ins _init(), communication with backend goes to _connect(). We need this for further support of backend-transfer migration of vhost-user-blk, as we'll need to postpone (or not do) initial communication to backend. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/virtio/vhost-user.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e45b74eddd..c5cb5ed528 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2270,21 +2270,12 @@ static int vhost_user_postcopy_notifier(NotifierWit= hReturn *notifier, return 0; } =20 -static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, - Error **errp) +static int vhost_user_backend_connect(struct vhost_dev *dev, Error **errp) { uint64_t features, ram_slots; - struct vhost_user *u; - VhostUserState *vus =3D (VhostUserState *) opaque; + struct vhost_user *u =3D dev->opaque; int err; =20 - assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER); - - u =3D g_new0(struct vhost_user, 1); - u->user =3D vus; - u->dev =3D dev; - dev->opaque =3D u; - err =3D vhost_user_get_features(dev, &features); if (err < 0) { error_setg_errno(errp, -err, "vhost_backend_init failed"); @@ -2292,7 +2283,7 @@ static int vhost_user_backend_init(struct vhost_dev *= dev, void *opaque, } =20 if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { - bool supports_f_config =3D vus->supports_config || + bool supports_f_config =3D u->user->supports_config || (dev->config_ops && dev->config_ops->vhost_dev_config_notifier= ); uint64_t protocol_features; =20 @@ -2408,6 +2399,22 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, return 0; } =20 +static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, + Error **errp) +{ + struct vhost_user *u; + VhostUserState *vus =3D (VhostUserState *) opaque; + + assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER); + + u =3D g_new0(struct vhost_user, 1); + u->user =3D vus; + u->dev =3D dev; + dev->opaque =3D u; + + return 0; +} + static int vhost_user_backend_cleanup(struct vhost_dev *dev) { struct vhost_user *u; @@ -3133,6 +3140,7 @@ void vhost_user_qmp_status(struct vhost_dev *dev, Vir= tioStatus *status) const VhostOps user_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_USER, .vhost_backend_init =3D vhost_user_backend_init, + .vhost_backend_connect =3D vhost_user_backend_connect, .vhost_backend_cleanup =3D vhost_user_backend_cleanup, .vhost_backend_memslots_limit =3D vhost_user_memslots_limit, .vhost_backend_no_private_memslots =3D vhost_user_no_private_memsl= ots, --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615079; cv=none; d=zohomail.com; s=zohoarc; b=bPxgKyi0t2RBN0H7NwWV/a80vVrK9+U/w1Ln8/0zB7UifMxADsVBc71lMGeA48lCdQrcYqD8ZWrVPfdfgs8V4wFC0OR3SuK4YGGvZ6Y56YRhMCiIKHNzpyN9NSDSixdfvmn7EbAmCz0p16f82NtfB2kGyWD+lWeOQj0mmsHw5xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615079; 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=3Rz+MXzzYC9OgDI+uA/Nsz/cK/rJU7nqiFJFVGluT4g=; b=UTcO0Hy1yN0Vgu3YfDfH9wSThrM3VoUp3mNcQyniVKu7p9V9lYQC0TXBa6RJiSKzUKnmzpGGoBIflowTARQOUmG8+LB5FCdmXlTrp0m2m9FpyM+Olyp5jelX8uoyDFMkk3vmGPfm2F5LLVWe/HIrh4RmHQyZCnOKIz6QhPH/5V4= 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 1760615079219450.06854842751966; Thu, 16 Oct 2025 04:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNc-0007UJ-8d; Thu, 16 Oct 2025 07:42:48 -0400 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 1v9MMh-00076q-Uq; Thu, 16 Oct 2025 07:41:52 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMS-0003Tj-CU; Thu, 16 Oct 2025 07:41:46 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 9BF02C01C8; Thu, 16 Oct 2025 14:41:29 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-8uCyA1Hn; Thu, 16 Oct 2025 14:41:29 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614889; bh=3Rz+MXzzYC9OgDI+uA/Nsz/cK/rJU7nqiFJFVGluT4g=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=k8DeWtLalt45sEpF4NnXdUFO9fIJwFvKKK50gyo1msyp0vuRBV/eHzoQCGMTC4Gbv vNM2NhbnIArh3dpCbOSrhxENkZGW41kopIVBxTzr05rVI8kmPi3FxQhS1E1Wt0CADA r9cveRYp/fBi8opR2QJp6cF/6TIPiaqpQlRisqRU= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 07/25] vhost-user-blk: vhost_user_blk_connect() move connected check to caller Date: Thu, 16 Oct 2025 14:40:44 +0300 Message-ID: <20251016114104.1384675-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615081769154100 Content-Type: text/plain; charset="utf-8" vhost_user_blk_connect() has two callers: - vhost_user_blk_realize_connect(), which directly set .connected =3D false before call - vhost_user_blk_event(), where we want this check Move the check to the only caller which needs it, to simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a92426f18c..57214a69cd 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -352,9 +352,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) =20 trace_vhost_user_blk_connect_in(vdev); =20 - if (s->connected) { - return 0; - } + assert(!s->connected); =20 s->dev.num_queues =3D s->num_queues; s->dev.nvqs =3D s->num_queues; @@ -411,10 +409,12 @@ static void vhost_user_blk_event(void *opaque, QEMUCh= rEvent event) =20 switch (event) { case CHR_EVENT_OPENED: - if (vhost_user_blk_connect(dev, &local_err) < 0) { - error_report_err(local_err); - qemu_chr_fe_disconnect(&s->chardev); - return; + if (!s->connected) { + if (vhost_user_blk_connect(dev, &local_err) < 0) { + error_report_err(local_err); + qemu_chr_fe_disconnect(&s->chardev); + return; + } } break; case CHR_EVENT_CLOSED: --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615189; cv=none; d=zohomail.com; s=zohoarc; b=ZQ5H2c28Ie748foPwQqwE77lxM+YTYONnusarLOPZMFwIVXHrQr1lQW/w6DiDx5OeZS9NRYM8Lcsc7of0s3NtAXA0a5JGRxRVmgKj+90MsPc5QBHN1vCdRYQdIk5aWRZIRGBe//0wo5Wy+8L03hXKhkO8iD0I5aPUgBeF5NwWec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615189; 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=zVW4n0TNZFrmZj1Vy/sRMQ5Ndb91OuTRaE6rQcdPF1k=; b=T+pO1NdlcOmWVr3Meodw0dXyyMxAbcVPBKxuSRab/o9NlJ1Mj/nfvHzWVlk96N+vwwI0hjEadGipf6oG7f9S1IUMKSqkCnl1o0cjUG5pJ9H9II0A1lbr93D/8GvEBQSHGf58Yiec4D3XUbpoQEnAaln4sjZo20IMK2InhtPWJ9g= 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 1760615189821443.62402383034964; Thu, 16 Oct 2025 04:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNX-0007Ol-LR; Thu, 16 Oct 2025 07:42:43 -0400 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 1v9MMh-00076r-Vo; Thu, 16 Oct 2025 07:41:52 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMU-0003To-Em; Thu, 16 Oct 2025 07:41:47 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 4882AC01CC; Thu, 16 Oct 2025 14:41:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-KVY9CN4h; Thu, 16 Oct 2025 14:41:29 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614889; bh=zVW4n0TNZFrmZj1Vy/sRMQ5Ndb91OuTRaE6rQcdPF1k=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=mNSSCbFaas5f8BSQF4d5FyOViFiW+hLoUV29VImNn6IwAIS4NrhcxALSxqJNny8rh FxzpjI9aBZW0hPdzqqxFsN7tTwKmR3gv++z06tJVGfp2PNwPuKm6eCBEDyAoSlaw/s oDDNBTVFOVmbW6kwheQWnObG6e4gMHjtkx/QSrsc= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 08/25] vhost-user-blk: vhost_user_blk_connect(): call vhost_dev_connect() Date: Thu, 16 Oct 2025 14:40:45 +0300 Message-ID: <20251016114104.1384675-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615193070154100 Content-Type: text/plain; charset="utf-8" Call vhost_dev_connect() directly, to simplify further refactoring. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 57214a69cd..f2ecf81e4d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -363,7 +363,12 @@ static int vhost_user_blk_connect(DeviceState *dev, Er= ror **errp) =20 s->vhost_user.supports_config =3D true; ret =3D vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, - true, errp); + false, errp); + if (ret < 0) { + return ret; + } + + ret =3D vhost_dev_connect(&s->dev, errp); if (ret < 0) { return ret; } --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760614987; cv=none; d=zohomail.com; s=zohoarc; b=ar7g+eLWhvj1l6+LF8Ya0FzJCPIh6gzkfOj++98+x4+zM5SIz2vr6no7o4GR00WnBQMqQmbXhfzsfYN90x8jGIee8AY7vRcYPssWFLpUjMCJ2MOkrVOQs4PnaOlKlp35nygw02IRtSPKOD8rvU32CA66u9x6S+RyqLeXiOXTaJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760614987; 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=PJRYSlh/MYnWxyKJiwlYbe6xhlYoS+CYlv2eltv+hYU=; b=EUuKoIgS6+wclIubTrvgkmNAq+cOxBfFtgs+qyP2FuGWQLPGngqQw5LVRIw0tGvrlzewdBsTA0CuU4R+MgA+IDA1MLM4/oOMmXByeF6lWhhaQUMg+kRrV2nVM5a45wlQSMiS/bU28bW6VsyKD1rTtWx5N9M0VLyCpCmHnNp09hY= 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 1760614987233204.21833428302762; Thu, 16 Oct 2025 04:43:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNL-0007Gs-5U; Thu, 16 Oct 2025 07:42:33 -0400 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 1v9MMa-000757-IW; Thu, 16 Oct 2025 07:41:44 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMS-0003Tt-5y; Thu, 16 Oct 2025 07:41:40 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id F2BFBC01CF; Thu, 16 Oct 2025 14:41:30 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-Tij31T1z; Thu, 16 Oct 2025 14:41:30 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614890; bh=PJRYSlh/MYnWxyKJiwlYbe6xhlYoS+CYlv2eltv+hYU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=P0Ux5ni957+92wSL4EifqrF03NrY30VNtyIlretVkHgJOf3CdaqX8BbK7FmX6aH94 +gGTx4uzS9gEQ+7zfuL4qaYEBGRJaLFRZsnGSaK7m84uyaxtDmz+Rs6pROYZGaSya+ zRwSM/XegeZgvB3YNg4i8kga2tYfu/i4ex5+yrJw= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 09/25] vhost-user-blk: rename vhost_user_blk_connect to vhost_user_blk_init Date: Thu, 16 Oct 2025 14:40:46 +0300 Message-ID: <20251016114104.1384675-10-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615003527154100 Content-Type: text/plain; charset="utf-8" The function does both vhost_dev_init() and vhost_dev_connect(). Following interface of vhost_dev_init(), and preparing to further refactoring, let's rename to _init() and add boolean "connect" parameter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/block/trace-events | 2 ++ hw/block/vhost-user-blk.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/block/trace-events b/hw/block/trace-events index dbaa5ca6cb..9f00412a99 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -63,6 +63,8 @@ vhost_user_blk_start_in(void *vdev) "vdev %p" vhost_user_blk_start_out(void *vdev) "vdev %p" vhost_user_blk_stop_in(void *vdev) "vdev %p" vhost_user_blk_stop_out(void *vdev) "vdev %p" +vhost_user_blk_init_in(void *vdev) "vdev %p" +vhost_user_blk_init_out(void *vdev) "vdev %p" vhost_user_blk_connect_in(void *vdev) "vdev %p" vhost_user_blk_connect_out(void *vdev) "vdev %p" vhost_user_blk_device_realize_in(void *vdev) "vdev %p" diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index f2ecf81e4d..c31c265a0e 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -344,13 +344,16 @@ static void vhost_user_blk_reset(VirtIODevice *vdev) vhost_dev_free_inflight(s->inflight); } =20 -static int vhost_user_blk_connect(DeviceState *dev, Error **errp) +static int vhost_user_blk_init(DeviceState *dev, bool connect, Error **err= p) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserBlk *s =3D VHOST_USER_BLK(vdev); int ret =3D 0; =20 - trace_vhost_user_blk_connect_in(vdev); + trace_vhost_user_blk_init_in(vdev); + + /* TODO: implement support for connect=3Dfalse */ + assert(connect); =20 assert(!s->connected); =20 @@ -380,7 +383,7 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) ret =3D vhost_user_blk_start(vdev, errp); } =20 - trace_vhost_user_blk_connect_out(vdev); + trace_vhost_user_blk_init_out(vdev); =20 return ret; } @@ -415,7 +418,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event) switch (event) { case CHR_EVENT_OPENED: if (!s->connected) { - if (vhost_user_blk_connect(dev, &local_err) < 0) { + if (vhost_user_blk_init(dev, true, &local_err) < 0) { error_report_err(local_err); qemu_chr_fe_disconnect(&s->chardev); return; @@ -447,7 +450,7 @@ static int vhost_user_blk_realize_connect(VHostUserBlk = *s, Error **errp) return ret; } =20 - ret =3D vhost_user_blk_connect(dev, errp); + ret =3D vhost_user_blk_init(dev, true, errp); if (ret < 0) { qemu_chr_fe_disconnect(&s->chardev); return ret; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615175; cv=none; d=zohomail.com; s=zohoarc; b=XFoTDnkGDYZ6yJecgiD2SmxV6NRsjXPgWCMsAHNaLYQ/Dr3buQmNfL0ySIG5di7JXLiBf3zPtJOUsv9/H7q5X/nLSP2Vx3SYRETVsx8XsFBT2XGvwopk/EftkQUEav1om27wiJlYD836nsGEeWxaVpPNhg5I4YixoSFJV0eeLa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615175; 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=s9yCrQBHmEqUJP+BAtrGs9xnsIszRjeHBLrqv/k9/kY=; b=YQBKHI3kH1G8ulCLsQV9k1rxkkNhjPufSxDRwfy26UaMPgsn7mgtIm6LuaKuxODcKhXSiQSO6NfE22vv19UJorWaxI4WiKrppeVIfNmnQjfsT/q+pqcO4ti6zIUfDB04ENtoB3zfpbaEstk1vhaSfzLwK5vAiwskNxUI6Q4VLzU= 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 1760615175976177.5264286109316; Thu, 16 Oct 2025 04:46:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNW-0007O3-CG; Thu, 16 Oct 2025 07:42:42 -0400 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 1v9MMm-00077W-5Q; Thu, 16 Oct 2025 07:41:57 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMa-0003V1-UX; Thu, 16 Oct 2025 07:41:52 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id A45E8C01C0; Thu, 16 Oct 2025 14:41:31 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-kbTFYAzO; Thu, 16 Oct 2025 14:41:31 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614891; bh=s9yCrQBHmEqUJP+BAtrGs9xnsIszRjeHBLrqv/k9/kY=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=nGMFivfrKNwEYIg4qwdqbFWpAbeT2qjkF2VfBM6/5cHP4iADYxGoBuyFaeYKhyjCE nTuClrPtD2w8Gm2KvZ4UojN8fA31c+j9bTunxgzi2ta2nXtoE9VELDvlS43fuq4mq2 aKRDhC38KQ64KEkYt2XCUupg+hX9++fFFxuTvOhs= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 10/25] vhost-user-blk: split vhost_user_blk_init() Date: Thu, 16 Oct 2025 14:40:47 +0300 Message-ID: <20251016114104.1384675-11-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615181241158500 Content-Type: text/plain; charset="utf-8" Split it into _init() and _connect() part, following pattern of vhost_dev_init / vhost_dev_connect. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index c31c265a0e..9c727c3977 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -58,6 +58,7 @@ static const int user_feature_bits[] =3D { }; =20 static void vhost_user_blk_event(void *opaque, QEMUChrEvent event); +static int vhost_user_blk_connect(DeviceState *dev, Error **errp); =20 static void vhost_user_blk_update_config(VirtIODevice *vdev, uint8_t *conf= ig) { @@ -352,9 +353,6 @@ static int vhost_user_blk_init(DeviceState *dev, bool c= onnect, Error **errp) =20 trace_vhost_user_blk_init_in(vdev); =20 - /* TODO: implement support for connect=3Dfalse */ - assert(connect); - assert(!s->connected); =20 s->dev.num_queues =3D s->num_queues; @@ -371,6 +369,29 @@ static int vhost_user_blk_init(DeviceState *dev, bool = connect, Error **errp) return ret; } =20 + if (connect) { + ret =3D vhost_user_blk_connect(dev, errp); + if (ret < 0) { + return ret; + } + } + + trace_vhost_user_blk_init_out(vdev); + + return 0; +} + +static int vhost_user_blk_connect(DeviceState *dev, + Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + int ret =3D 0; + + trace_vhost_user_blk_connect_in(vdev); + + assert(!s->connected); + ret =3D vhost_dev_connect(&s->dev, errp); if (ret < 0) { return ret; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615393; cv=none; d=zohomail.com; s=zohoarc; b=RviVXfwoo0+GdOd5WxWlkPpHSdhQCaiNbOri96Jdh4pr/XqD3IiS6EAv/hmvWfiS+rdo6oXDvZkdTRxa7R09KQX6wKAyYe4m+TWd2EtD0XEUCUzdnT6Ra71dlFqsKwj9T7qLKIHsaDoiRacZdt4F8Ly/DoAWZYXh7TD47+Mtj3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615393; 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=SF+Ue84XhT+g2RO+Jl8Tk8MZ2adI/UHd1mhcu8QJuxs=; b=Carb6r+2DSnXYLFWwoK9LDXr9pTy1D74u4MyCPpB9b49xODyw2CDuMwfxNJtyT40DZAKo54D6qVuG1weQPC7zHx5y3LfczV0m5/zpVukcPrfjCSdtTmeSFDIdCw5emG1DXoCY9HqVPJFgcDTOlvArggfL9gbCj5TNHCowQV6pA4= 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 176061539374343.562253426580696; Thu, 16 Oct 2025 04:49:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNK-0007Fn-Vx; Thu, 16 Oct 2025 07:42:31 -0400 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 1v9MMp-00078K-9N; Thu, 16 Oct 2025 07:41:59 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMa-0003V0-RV; Thu, 16 Oct 2025 07:41:54 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 543BEC01CB; Thu, 16 Oct 2025 14:41:32 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-cwh9id8l; Thu, 16 Oct 2025 14:41:31 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614891; bh=SF+Ue84XhT+g2RO+Jl8Tk8MZ2adI/UHd1mhcu8QJuxs=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Q0FyYiPede9zuXeL3XOfmFfI1nsupeMyRbH+AoYJ+K9lzRlMaf5x+2m7P2Ks14pnV 0xP8ZM1JYLcUs7GBpF34ir9uQiGhXQ2eY7gasFzKNhpr5RmZtVVC8yIL5cSKFW6Ol4 OG3a89Rs7DcC5nxGfsbmyCIB6SdIwT6QaovbXt5M= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 11/25] vhost-user-blk: move initial reconnect loop to separate function Date: Thu, 16 Oct 2025 14:40:48 +0300 Message-ID: <20251016114104.1384675-12-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615397423158500 Content-Type: text/plain; charset="utf-8" Simplify _realize function, and prepare to further changes. While being here, also rename virtio_err: label to more generic fail:, virtio_err doesn't improve readability here. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 54 +++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9c727c3977..36e32229ad 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -489,14 +489,40 @@ static int vhost_user_blk_realize_connect(VHostUserBl= k *s, Error **errp) return 0; } =20 -static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) +static int vhost_user_blk_realize_connect_loop(VHostUserBlk *s, Error **er= rp) { ERRP_GUARD(); + DeviceState *dev =3D DEVICE(s); + int ret, retries =3D VU_REALIZE_CONN_RETRIES; + + assert(!*errp); + do { + if (*errp) { + error_prepend(errp, "Reconnecting after error: "); + error_report_err(*errp); + *errp =3D NULL; + } + ret =3D vhost_user_blk_realize_connect(s, errp); + } while (ret < 0 && retries--); + + if (ret < 0) { + return ret; + } + + /* we're fully initialized, now we can operate, so add the handler */ + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, + vhost_user_blk_event, NULL, (void *)dev, + NULL, true); + + return 0; +} + +static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) +{ VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserBlk *s =3D VHOST_USER_BLK(vdev); size_t config_size; - int retries; - int i, ret; + int i; =20 trace_vhost_user_blk_device_realize_in(vdev); =20 @@ -540,31 +566,15 @@ static void vhost_user_blk_device_realize(DeviceState= *dev, Error **errp) s->inflight =3D g_new0(struct vhost_inflight, 1); s->vhost_vqs =3D g_new0(struct vhost_virtqueue, s->num_queues); =20 - retries =3D VU_REALIZE_CONN_RETRIES; - assert(!*errp); - do { - if (*errp) { - error_prepend(errp, "Reconnecting after error: "); - error_report_err(*errp); - *errp =3D NULL; - } - ret =3D vhost_user_blk_realize_connect(s, errp); - } while (ret < 0 && retries--); - - if (ret < 0) { - goto virtio_err; + if (vhost_user_blk_realize_connect_loop(s, errp) < 0) { + goto fail; } =20 - /* we're fully initialized, now we can operate, so add the handler */ - qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, - vhost_user_blk_event, NULL, (void *)dev, - NULL, true); - trace_vhost_user_blk_device_realize_out(vdev); =20 return; =20 -virtio_err: +fail: g_free(s->vhost_vqs); s->vhost_vqs =3D NULL; g_free(s->inflight); --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615046; cv=none; d=zohomail.com; s=zohoarc; b=BqibRfx8aJOPgYlLniQFCZ6od2L1I4CumgglB2QatYwef4/1PK/GAEIgnTRswZ+aGHj/vNFiVa2NF5HwUZMZCST1hNVDkwFE2XKV4MuSTeleq24JLlJEwOSwTVxBw0D+lTNcSWmEQyf4rQn4UjTcz0F7bPH06NTvc0piVe7e7fA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615046; 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=BasLlhPIqn3NnKJfMKRrLdXARiWRvWkkx7fEK4BDITM=; b=mynP43Qz8HlA/msrB3RDQC6E7kykvheIrCyB1AEE5dkYzR3Xd6u/Bea8I1a8NBqrMQuEnsX/vPm5S4pPuOoOa9mlOTLTTkiWoaoLWVNZhq17GjGW2qrQ1f1EoXwo8fcEeU3Teii5cOXZ9aIiTpyzyu3IyGhmFpkKp3jiJbCVbRE= 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 1760615046072132.49045416317767; Thu, 16 Oct 2025 04:44:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNb-0007SQ-6n; Thu, 16 Oct 2025 07:42:47 -0400 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 1v9MN2-0007BJ-GJ; Thu, 16 Oct 2025 07:42:14 -0400 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 1v9MMt-0003VV-B4; Thu, 16 Oct 2025 07:42:08 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 0144EC01D2; Thu, 16 Oct 2025 14:41:33 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-FQH2tMY6; Thu, 16 Oct 2025 14:41:32 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614892; bh=BasLlhPIqn3NnKJfMKRrLdXARiWRvWkkx7fEK4BDITM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=aUzwRa9NcHF2nAN8O9zds2QgLx91o99px4R3pRqrBvtXwtbLu1Zlnp4rsllZougzg WesjxSQ5o0pHew+GF26TcNxR6Mr/OaZ/hLy6HRxfm8OZnWxynIOwNEEGVzNcajxfVE VKNaGxwGH4M2Yi4Aakfx9LmoJVqKPjPscH4MNIvo= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 12/25] vhost-user-blk: move first vhost_user_blk_init() to _realize() Date: Thu, 16 Oct 2025 14:40:49 +0300 Message-ID: <20251016114104.1384675-13-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615047322158500 Content-Type: text/plain; charset="utf-8" We'll need to postpone further connecting/reconnecting logic to the later point to support backend-transfer migration for vhost-user-blk. For now, move first call to vhost_user_blk_init() to _realize() (this call will not be postponed). To support this, we also have to move re-initialization to vhost_user_blk_realize_connect_loop(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/block/vhost-user-blk.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 36e32229ad..af4a97b8e4 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -464,14 +464,12 @@ static int vhost_user_blk_realize_connect(VHostUserBl= k *s, Error **errp) DeviceState *dev =3D DEVICE(s); int ret; =20 - s->connected =3D false; - ret =3D qemu_chr_fe_wait_connected(&s->chardev, errp); if (ret < 0) { return ret; } =20 - ret =3D vhost_user_blk_init(dev, true, errp); + ret =3D vhost_user_blk_connect(dev, errp); if (ret < 0) { qemu_chr_fe_disconnect(&s->chardev); return ret; @@ -501,7 +499,16 @@ static int vhost_user_blk_realize_connect_loop(VHostUs= erBlk *s, Error **errp) error_prepend(errp, "Reconnecting after error: "); error_report_err(*errp); *errp =3D NULL; + + s->connected =3D false; + + ret =3D vhost_user_blk_init(dev, false, errp); + if (ret < 0) { + /* No reason to retry initialization */ + return ret; + } } + ret =3D vhost_user_blk_realize_connect(s, errp); } while (ret < 0 && retries--); =20 @@ -566,6 +573,10 @@ static void vhost_user_blk_device_realize(DeviceState = *dev, Error **errp) s->inflight =3D g_new0(struct vhost_inflight, 1); s->vhost_vqs =3D g_new0(struct vhost_virtqueue, s->num_queues); =20 + if (vhost_user_blk_init(dev, false, errp) < 0) { + goto fail; + } + if (vhost_user_blk_realize_connect_loop(s, errp) < 0) { goto fail; } --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615045; cv=none; d=zohomail.com; s=zohoarc; b=Oeim0uqZWTY5cDn1WnHmHBSWnsCqn98zUYxB2/s+dwD5WTKiC71eW14y7NEG3V/BGrUdN85lK8XWAaL7Cp91fj8Sn4LsKRPmolIweRdIVH0bhszPNbUzuW7BIOrEaLN82kY7NFDRqG7waPesUgiHZkOhJnrLMCvI+NDScf9qoeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615045; 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=xg5rt25IH6Si30MHS9JyIgSHUQPJwjGNETHZfmCEbZ4=; b=SycwZg6m820yDAg/uzk2SLmlbrGug5eSRRdh9RmXpFoq7s70K0v0k7L4Cek+ifBfrFFW4VXIqZIWUxud+wrBnHsm5gZAHn6VhMVUyxzCottMpSGSOy7cAKWE4GQ5gzv9IfO2DZKlRaPnLznRUWTg7+X0PNVoumPD/hv2qwZuwKo= 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 1760615045809161.91381044046636; Thu, 16 Oct 2025 04:44:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNY-0007QO-L7; Thu, 16 Oct 2025 07:42:44 -0400 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 1v9MMq-00078i-HS; Thu, 16 Oct 2025 07:42:00 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMf-0003Vh-Hm; Thu, 16 Oct 2025 07:41:58 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id AC05AC01D5; Thu, 16 Oct 2025 14:41:33 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-3b7thUw0; Thu, 16 Oct 2025 14:41:33 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614893; bh=xg5rt25IH6Si30MHS9JyIgSHUQPJwjGNETHZfmCEbZ4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=XLs9mjPTUIwnQpx98i8Pwv5R+czk+e2FjvkWagPDIrJFq8TBTIOgc70jBjHvyT3i1 O3o4/ixHalogJg4C3rWbzxjR/WUd3j8EEGoyKE94kZhibr7xFP6T209DqLYfkZ8FuL VxN7Fvq/T6jNpKoHj23Uo60pAY+borwqyxdSCCBQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 13/25] vhost-user-blk: postpone connect to pre-incoming Date: Thu, 16 Oct 2025 14:40:50 +0300 Message-ID: <20251016114104.1384675-14-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615047332158500 Content-Type: text/plain; charset="utf-8" That's a preparation for further backend-transfer migration for vhost-user-blk. At initialization time we don't know will user enable backent-transfer (by setting migration parameter) or not. At time of pre-incoming, we know all migration parameters and capabilities. So, now, let's postpone connecting up to pre-incoming for incoming migration. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index af4a97b8e4..ffdd600526 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -577,8 +577,10 @@ static void vhost_user_blk_device_realize(DeviceState = *dev, Error **errp) goto fail; } =20 - if (vhost_user_blk_realize_connect_loop(s, errp) < 0) { - goto fail; + if (!runstate_check(RUN_STATE_INMIGRATE)) { + if (vhost_user_blk_realize_connect_loop(s, errp) < 0) { + goto fail; + } } =20 trace_vhost_user_blk_device_realize_out(vdev); @@ -636,10 +638,18 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Vir= tIODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_pre_incoming(void *opaque, Error **errp) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(opaque); + + return vhost_user_blk_realize_connect(s, errp) =3D=3D 0; +} + static const VMStateDescription vmstate_vhost_user_blk =3D { .name =3D "vhost-user-blk", .minimum_version_id =3D 1, .version_id =3D 1, + .pre_incoming =3D vhost_user_blk_pre_incoming, .fields =3D (const VMStateField[]) { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() @@ -647,7 +657,7 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { }; =20 static const Property vhost_user_blk_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), + DEFINE_PROP_CHR_NO_CONNECT("chardev", VHostUserBlk, chardev), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, VHOST_USER_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128), --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615396; cv=none; d=zohomail.com; s=zohoarc; b=O4Mp67zYZA3UIq84zUUxoNFvKFEkCK3nVMztnNfaPuB6JiihkofnS0RFF2+ERWqdEP7/kxLJE2Tf9ahUBaB9FMHnDCL0kpmR6wFX4szGOgWM5/HHA6thkCMPtGwiCHcyv09trDH9ihT0Hzas2CmJB14hIlcF3Gww19nqw7iHMJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615396; 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=oKQA85QXzsIVZqTNV9A3NCvsSHAUSiUk1m05STP30Ks=; b=PUL3vxeu+kiGbe9VchqOqWzVs27dC1FXZgJ8TM4oqKQyf4cqLl9zjIoGEfVT972w5fBqccxMJiKHHhymVxGvXBSWh132T5yOszfOGNsfARUUXV+kNOvcxrp8qFvTjoVaXJUcPmhnU5HKApohdw6aoXJD4yhrJIiOK+/VR7pF7T8= 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 1760615396267641.2809636855615; Thu, 16 Oct 2025 04:49:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNc-0007UM-Bg; Thu, 16 Oct 2025 07:42:48 -0400 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 1v9MMu-000797-3p; Thu, 16 Oct 2025 07:42:04 -0400 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 1v9MMi-0003Vi-7E; Thu, 16 Oct 2025 07:42:01 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 559D7C01D6; Thu, 16 Oct 2025 14:41:34 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-uHz8I142; Thu, 16 Oct 2025 14:41:33 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614893; bh=oKQA85QXzsIVZqTNV9A3NCvsSHAUSiUk1m05STP30Ks=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=omjAXTmUHf8Ltm7WpU+/GrDokWXI3xDuHIHDkPvYoaduwMG6jyUmvYKeXXhQyF/8a j4b/mdPn+8aXYKJufXzXEK71D29VCRh9d8wsPT0eJah7v4TxOLawYhnm5C50CsT0AU I4TTydTJbP+U41xn8I7QlI8/SeH6D5UkJB/tRbyg= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 14/25] virtio: introduce .skip_vhost_migration_log() handler Date: Thu, 16 Oct 2025 14:40:51 +0300 Message-ID: <20251016114104.1384675-15-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615401441158500 Content-Type: text/plain; charset="utf-8" For vhost user backend migration we'll need to disable memory logging on the device. Let's prepare a corresponding handler for the device. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Raphael Norwitz --- hw/virtio/vhost.c | 10 ++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 09d00e4d98..3e5192ec23 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1138,6 +1138,16 @@ static int vhost_migration_log(MemoryListener *liste= ner, bool enable) struct vhost_dev *dev =3D container_of(listener, struct vhost_dev, memory_listener); int r; + + if (dev->vdev) { + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(dev->vdev); + + if (vdc->skip_vhost_migration_log && + vdc->skip_vhost_migration_log(dev->vdev)) { + return 0; + } + } + if (enable =3D=3D dev->log_enabled) { return 0; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 7db8046766..620ee4e389 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -238,6 +238,8 @@ struct VirtioDeviceClass { /* May be called even when vdev->vhost_started is false */ struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); void (*toggle_device_iotlb)(VirtIODevice *vdev); + + bool (*skip_vhost_migration_log)(VirtIODevice *vdev); }; =20 void virtio_instance_init_common(Object *proxy_obj, void *data, --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615510; cv=none; d=zohomail.com; s=zohoarc; b=UO7sRYCOqlq0aL2o9WvJjY6bYuvAe1Spe02EKV8dqr5TRHe5DwM7cdp+DPWYgL0RdiIyt/Idh1LCSHQPi38rBkC0DIeVmt6PXKmfaNzjz3aEXItg4Mb+lanqRSdOaodfOEXtev1Q02YWLzNUeucZnDmNZjlJSxb/shRzaWEwt3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615510; 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=ATBOk7y2BkgORhsGkD3qM3CJxtTyEmK5hDTvCDCS0bI=; b=lqB4ikeE18zV8oG5kpXSAO/kveLiECEuUk9LaOjcleLKY5WoXQUZOamKEiZDTqsx8WEHEsKMTG8gu+ck/+mg4H24XXpdSCPioIX6vnAoGMzwnqAht3f4wZ9wjZSPyKh5VeuwQo0UzXwxQ0YAytNppelxmbGpLi8Ex9YgNkpmTQk= 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 17606155106985.1615512256120155; Thu, 16 Oct 2025 04:51:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNZ-0007Qp-AT; Thu, 16 Oct 2025 07:42:45 -0400 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 1v9MMt-00078y-6q; Thu, 16 Oct 2025 07:42:03 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMi-0003Vg-4r; Thu, 16 Oct 2025 07:42:01 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 178FBC01D9; Thu, 16 Oct 2025 14:41:35 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-8SW4HDUx; Thu, 16 Oct 2025 14:41:34 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614894; bh=ATBOk7y2BkgORhsGkD3qM3CJxtTyEmK5hDTvCDCS0bI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=DK2q2cFa+YysBJZ7APancKjLfoPdtnagj6nH30xp4wTDn4U07tbKBm57dk1Qk3R7Z qCcjZNhy/CYtrrAAawGohBAcECSEJ1J9X1GrigwLlBGerNwlJ+xdC94hc6Nu1mwGFi 78Oi1lyUx157LRTtBeJ6mVv1GlNJ736m3eMiu2Sw= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com, Peter Xu Subject: [PATCH v2 15/25] migration: introduce vmstate_event_notifier Date: Thu, 16 Oct 2025 14:40:52 +0300 Message-ID: <20251016114104.1384675-16-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615512850154100 Content-Type: text/plain; charset="utf-8" This will be used to support backend-transfer migration for vhost-user-blk, we'll migrate event notifier fds through migration stream, to avoid extra contact with backend. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Peter Xu --- include/migration/vmstate.h | 7 ++++ migration/meson.build | 1 + migration/vmstate-event-notifier.c | 54 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 migration/vmstate-event-notifier.c diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f243518fb5..7f1f1c166a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1294,4 +1294,11 @@ void vmstate_register_ram_global(struct MemoryRegion= *memory); =20 bool vmstate_check_only_migratable(const VMStateDescription *vmsd); =20 +extern const VMStateDescription vmstate_event_notifier; + +#define VMSTATE_EVENT_NOTIFIER(_field, _struct) \ + VMSTATE_STRUCT(_field, _struct, 0, vmstate_event_notifier, \ + EventNotifier) + + #endif diff --git a/migration/meson.build b/migration/meson.build index 16909d54c5..b5341ae0cb 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -5,6 +5,7 @@ migration_files =3D files( 'xbzrle.c', 'vmstate-types.c', 'vmstate.c', + 'vmstate-event-notifier.c', 'qemu-file.c', 'yank_functions.c', ) diff --git a/migration/vmstate-event-notifier.c b/migration/vmstate-event-n= otifier.c new file mode 100644 index 0000000000..2076eec961 --- /dev/null +++ b/migration/vmstate-event-notifier.c @@ -0,0 +1,54 @@ +/* + * Event notifier migration support + * Copyright (c) Yandex Technologies LLC, 2025 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/event_notifier.h" +#include "migration/vmstate.h" + +static int event_notifier_pre_save(void *opaque) +{ + struct EventNotifier *e =3D opaque; + + if (!e->initialized || e->rfd !=3D e->wfd) { + return -1; + } + + return 0; +} + +static int event_notifier_pre_load(void *opaque) +{ + struct EventNotifier *e =3D opaque; + + if (e->initialized) { + return -1; + } + + return 0; +} + +static int event_notifier_post_load(void *opaque, int version_id) +{ + struct EventNotifier *e =3D opaque; + + if (e->rfd < 0) { + return -1; + } + + e->wfd =3D e->rfd; + e->initialized =3D true; + + return 0; +} + +const VMStateDescription vmstate_event_notifier =3D { + .name =3D "event-notifier", + .pre_save =3D event_notifier_pre_save, + .pre_load =3D event_notifier_pre_load, + .post_load =3D event_notifier_post_load, + .fields =3D (const VMStateField[]){VMSTATE_FD(rfd, EventNotifier), + VMSTATE_END_OF_LIST()}, +}; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615200; cv=none; d=zohomail.com; s=zohoarc; b=mv0pXOOP/Q5ngY2yh/A66758kn6Vo08fLujnO4K+wWiWWguRiCsIcgGQETEUUheocJa0cqvGfltMP/8Lan7M6k7KwUbO7vqkxeEfBS4uNwfSuUZ4dGtSYfvC0Wf3aPIIc0pglccfuUl2b4KeJpMAYD2ouQZqYiwscnqDDHdLafY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615200; 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=EvwL8eyab7no1GJoMEbPxt58P+5KUvNjBpLEjfyiDkg=; b=GXlQyuoTGE+2X9A5OiQJyp3Ch6l7HvVSF0Ipw3saVB0a4ETLqgzxiqxHV2Kh1e4RCsD+7ggw0dc5PY0zECuzQ9fo9PSoWef9SJj2GDbD9k7GmAD19Ue1MYmk6k/qbJV2zbxBNCMdnhDyd2Vv08QFcqUStzdQjd28/sfZwry/V/E= 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 1760615200524311.57120476295063; Thu, 16 Oct 2025 04:46:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNY-0007QH-3z; Thu, 16 Oct 2025 07:42:44 -0400 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 1v9MMw-00079U-5R; Thu, 16 Oct 2025 07:42:06 -0400 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 1v9MMn-0003WC-7X; Thu, 16 Oct 2025 07:42:03 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id C93BEC01DB; Thu, 16 Oct 2025 14:41:35 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-RYE1Ekdu; Thu, 16 Oct 2025 14:41:35 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614895; bh=EvwL8eyab7no1GJoMEbPxt58P+5KUvNjBpLEjfyiDkg=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=BcxDl4YTma2QtPqK/1IwlM1blnT5tiF4RQWapBzF0vU1RSdKAioQFmLBOlU2QE/cx s/N8LoCVcVosZN02pg9J7dtkZ2s28sR4m95uN6phvVCzHiGa2COQ1bp+VxSlwL0Xs3 sm3vzGJ3kHz5hBhMoeq7Wfni7MlWv7m5WitY3u/I= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 16/25] chardev: add .chr_get_client() handler Date: Thu, 16 Oct 2025 14:40:53 +0300 Message-ID: <20251016114104.1384675-17-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615203392154100 Content-Type: text/plain; charset="utf-8" A pair for .char_add_client(), to be used to support backend-transfer migration of chardev attached to vhost-user-blk in following commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- chardev/char-socket.c | 7 +++++++ chardev/char.c | 6 ++++++ include/chardev/char.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 0a5738c158..51bb9d0a2d 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -929,6 +929,12 @@ static int tcp_chr_new_client(Chardev *chr, QIOChannel= Socket *sioc) return 0; } =20 +static int tcp_chr_get_client(Chardev *chr) +{ + SocketChardev *s =3D SOCKET_CHARDEV(chr); + + return s->sioc->fd; +} =20 static int tcp_chr_add_client(Chardev *chr, int fd) { @@ -1591,6 +1597,7 @@ static void char_socket_class_init(ObjectClass *oc, c= onst void *data) cc->get_msgfds =3D tcp_get_msgfds; cc->set_msgfds =3D tcp_set_msgfds; cc->chr_add_client =3D tcp_chr_add_client; + cc->chr_get_client =3D tcp_chr_get_client; cc->chr_add_watch =3D tcp_chr_add_watch; cc->chr_update_read_handler =3D tcp_chr_update_read_handler; =20 diff --git a/chardev/char.c b/chardev/char.c index b68d44e394..3c2ed972f1 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -247,6 +247,12 @@ int qemu_chr_add_client(Chardev *s, int fd) CHARDEV_GET_CLASS(s)->chr_add_client(s, fd) : -1; } =20 +int qemu_chr_get_client(Chardev *s) +{ + return CHARDEV_GET_CLASS(s)->chr_get_client ? + CHARDEV_GET_CLASS(s)->chr_get_client(s) : -1; +} + static bool qemu_char_open(Chardev *chr, ChardevBackend *backend, const char *default_filename, Error **errp) { diff --git a/include/chardev/char.h b/include/chardev/char.h index d2e01f0f9c..671f64cb7e 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -216,6 +216,7 @@ void qemu_chr_be_update_read_handlers(Chardev *s, void qemu_chr_be_event(Chardev *s, QEMUChrEvent event); =20 int qemu_chr_add_client(Chardev *s, int fd); +int qemu_chr_get_client(Chardev *s); Chardev *qemu_chr_find(const char *name); =20 bool qemu_chr_has_feature(Chardev *chr, @@ -316,6 +317,9 @@ struct ChardevClass { /* accept the given fd */ int (*chr_add_client)(Chardev *chr, int fd); =20 + /* get fd back */ + int (*chr_get_client)(Chardev *chr); + /* wait for a connection */ int (*chr_wait_connected)(Chardev *chr, Error **errp); =20 --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615273; cv=none; d=zohomail.com; s=zohoarc; b=OBp3izOK64effUYeiCnGNpZd9GygvU456eahRJyo8+7hgvWnNx2nC6906jKzKKEpXmp71+JHP4VAQWg77NlnmqBXyc5iYFGRkB+hSmZT5lTDopITfDs3D7zd1Sdn7FaWXVXwUR/O8ER5JlQKxTaOZfQd7LYEAZEps/l2nKTzIKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615273; 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=X1G+ZxDLtXWMknznFE5+3sDhXLCW9VXnQrkCfUJ5yCQ=; b=HeaLtAL5DEF9g6qmT9+l6ioDGaVb8ZO6KObhBrH5IuyqIDUFuJpsaf5VnASvwptuRJpOMKz1ZyuFEg3XK5ifXF9xaY8HBB5nclD+QrTSPCUDF/8f5lTCOkIhgQv2fq0ypUX3DzyPt+6AxAwNrVzKghzQEb3Zhhvub+puF8VPMjQ= 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 1760615273955304.1026975849594; Thu, 16 Oct 2025 04:47:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNf-0007X8-Op; Thu, 16 Oct 2025 07:42:52 -0400 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 1v9MMy-0007AR-65; Thu, 16 Oct 2025 07:42:08 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMl-0003WB-PO; Thu, 16 Oct 2025 07:42:06 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 82A66C01DD; Thu, 16 Oct 2025 14:41:36 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-dWOYgbb6; Thu, 16 Oct 2025 14:41:36 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614896; bh=X1G+ZxDLtXWMknznFE5+3sDhXLCW9VXnQrkCfUJ5yCQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=r3D+gfzLnMsePSUofIw/fKGqxRqPP61uV7NdkumYpP83jF6sHBmeuiJHF75yIRcI1 WVIugTZqzTHXXnbyYGREcBJA3LPOfKEzUWcoGnr+iz73DpxgfiEmM7ptjyifogIRcE rWpu64D6hCjIeBeETu3baC4xKY8wkLBl6dDti3Qk= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 17/25] vhost: add inflight region backend-transfer vmstate Date: Thu, 16 Oct 2025 14:40:54 +0300 Message-ID: <20251016114104.1384675-18-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615276143158500 Content-Type: text/plain; charset="utf-8" Prepare for future backend-transfer migration of vhost-user-blk. Among other things we'll need to transfer the inflight region, let's prepare for this. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz --- hw/virtio/vhost.c | 26 ++++++++++++++++++++++++++ include/hw/virtio/vhost.h | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 3e5192ec23..63036f8214 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1975,6 +1975,32 @@ void vhost_get_features_ex(struct vhost_dev *hdev, } } =20 +static int vhost_inflight_backend_transfer_post_load(void *opaque, + int version_id) +{ + struct vhost_inflight *inflight =3D opaque; + + inflight->addr =3D mmap(0, inflight->size, PROT_READ | PROT_WRITE, + MAP_SHARED, inflight->fd, inflight->offset); + if (inflight->addr =3D=3D MAP_FAILED) { + return -EINVAL; + } + + return 0; +} + +const VMStateDescription vmstate_backend_transfer_vhost_inflight =3D { + .name =3D "vhost-inflight", + .post_load =3D vhost_inflight_backend_transfer_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_FD(fd, struct vhost_inflight), + VMSTATE_UINT64(size, struct vhost_inflight), + VMSTATE_UINT64(offset, struct vhost_inflight), + VMSTATE_UINT16(queue_size, struct vhost_inflight), + VMSTATE_END_OF_LIST() + } +}; + void vhost_ack_features_ex(struct vhost_dev *hdev, const int *feature_bits, const uint64_t *features) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index af46d4b5f2..94a0c75fc8 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -587,4 +587,9 @@ static inline int vhost_load_backend_state(struct vhost= _dev *dev, QEMUFile *f, } #endif =20 +extern const VMStateDescription vmstate_backend_transfer_vhost_inflight; +#define VMSTATE_BACKEND_TRANSFER_VHOST_INFLIGHT(_field, _state) \ + VMSTATE_STRUCT_POINTER(_field, _state, vmstate_inflight, \ + struct vhost_inflight) + #endif --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615246; cv=none; d=zohomail.com; s=zohoarc; b=G5I3VInYO5kN4R+296eyEUF8ltQ4GqbT6ONVCS7+12FDKGsQ8IzGj4BYX+nAVctn22DdS3rD/ZQeLAxoOefpxA7nwpbP0s4c7W+XlecjaGT7pdeVB75IfNmEu0gO/aGZNbdD8usqO0xiV9uembf65MUvxQHKdKxlEe9PNyJ1dxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615246; 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=bpYyRH+FH5+ms+TFU93oV6x9PSDyaNh07aiBxI/3YRc=; b=br8+vKbMNP7TYWj+Vl4VRtZ7YxKYwKSND6N1164VQWHwIzippJcMaqcfidXKsg1j7qV/5sGAZpl2T0YF1vTsUIefEwlq+u1Gjc5I6elV1UsZaFCqEt/KUptkIkH9pivWyNVj7p0MFC5plwm8GnCeKb05Du2NrBECMbOSEOqATbk= 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 1760615246934385.0184686803975; Thu, 16 Oct 2025 04:47:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNb-0007Sk-Is; Thu, 16 Oct 2025 07:42:47 -0400 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 1v9MMx-00079V-5o; Thu, 16 Oct 2025 07:42:07 -0400 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 1v9MMk-0003WL-F9; Thu, 16 Oct 2025 07:42:02 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 510E7C01DF; Thu, 16 Oct 2025 14:41:37 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-jWRYgAwK; Thu, 16 Oct 2025 14:41:36 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614896; bh=bpYyRH+FH5+ms+TFU93oV6x9PSDyaNh07aiBxI/3YRc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Sqbpc+alHMEB7F5+LCy/2E+v4XokjaMKFtsNcShpufQqZBFPuScB3DtUzpfIAbaKu Xk/nI7wCrWm6LKqlkxpblLr5DineKaFJBXfIUzNL4ov6c6VD/z9VqRFQGZueuBQ38J /5qMcjOv4mG7lcUsWMv43JGPdnQNZlq4Xb6sX3o4= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 18/25] chardev: introduce backend-transfer vmstate for chardev Date: Thu, 16 Oct 2025 14:40:55 +0300 Message-ID: <20251016114104.1384675-19-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615249755154100 Content-Type: text/plain; charset="utf-8" We'll need to transfer the chardev attached to vhost-user-blk, to support backend-transfer migration for vhost-user-blk. So, prepare chardev vmsd now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- chardev/char-backend-transfer.c | 52 +++++++++++++++++++++++++ chardev/meson.build | 1 + include/chardev/char-backend-transfer.h | 17 ++++++++ 3 files changed, 70 insertions(+) create mode 100644 chardev/char-backend-transfer.c create mode 100644 include/chardev/char-backend-transfer.h diff --git a/chardev/char-backend-transfer.c b/chardev/char-backend-transfe= r.c new file mode 100644 index 0000000000..f1a399c7fa --- /dev/null +++ b/chardev/char-backend-transfer.c @@ -0,0 +1,52 @@ +/* + * Event notifier migration support + * Copyright (c) Yandex Technologies LLC, 2025 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "chardev/char-fe.h" +#include "migration/vmstate.h" + +typedef struct CharBackendTransferTmp { + CharBackend *parent; + int fd; +} CharBackendTransferTmp; + +static int char_backend_transfer_pre_save(void *opaque) +{ + CharBackendTransferTmp *tmp =3D opaque; + + tmp->fd =3D qemu_chr_get_client(tmp->parent->chr); + if (tmp->fd < 0) { + return -1; + } + + return 0; +} + +static int char_backend_transfer_post_load(void *opaque, int version_id) +{ + CharBackendTransferTmp *tmp =3D opaque; + + return qemu_chr_add_client(tmp->parent->chr, tmp->fd); +} + +const VMStateDescription vmstate_backend_transfer_char_tmp =3D { + .name =3D "backend-transfer-char-tmp", + .pre_save =3D char_backend_transfer_pre_save, + .post_load =3D char_backend_transfer_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_FD(fd, CharBackendTransferTmp), + VMSTATE_END_OF_LIST() + }, +}; + +const VMStateDescription vmstate_backend_transfer_char =3D { + .name =3D "backend-transfer-char", + .fields =3D (const VMStateField[]) { + VMSTATE_WITH_TMP(CharBackend, CharBackendTransferTmp, + vmstate_backend_transfer_char_tmp), + VMSTATE_END_OF_LIST() + }, +}; diff --git a/chardev/meson.build b/chardev/meson.build index 56ee39ac0b..239c8cd072 100644 --- a/chardev/meson.build +++ b/chardev/meson.build @@ -31,6 +31,7 @@ chardev_ss =3D chardev_ss.apply({}) =20 system_ss.add(files( 'char-hmp-cmds.c', + 'char-backend-transfer.c', 'msmouse.c', 'wctablet.c', 'testdev.c')) diff --git a/include/chardev/char-backend-transfer.h b/include/chardev/char= -backend-transfer.h new file mode 100644 index 0000000000..2c3da5f836 --- /dev/null +++ b/include/chardev/char-backend-transfer.h @@ -0,0 +1,17 @@ +/* + * Event notifier migration support + * Copyright (c) Yandex Technologies LLC, 2025 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef CHAR_BACKEND_TRANSFER_H +#define CHAR_BACKEND_TRANSFER_H + +#include "qemu/typedefs.h" + +extern const VMStateDescription vmstate_backend_transfer_char; +#define VMSTATE_BACKEND_TRANSFER_CHARDEV(_field, _state) = \ + VMSTATE_STRUCT(_field, _state, 0, vmstate_backend_transfer_char, = \ + CharBackend) + +#endif --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615125; cv=none; d=zohomail.com; s=zohoarc; b=gM2zuBDnH4upYzgmsdwrqRliKfdnTak710EwicXWfKtEMCgnH1S59kJso8O/DMFF7MJMT2mj7BjNZJN+27yuQY98RAcnh1hW+L+vvQVV5OiV3c0CcGY8831tz41yJD7fY9pdswgzxHpUElBxrtjQxD+2+TpSlP94ISUsyBVpdMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615125; 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=4cgovY7tyDau9EmQRY+aKBap0SqRZ3wu+IcsVV5ZIew=; b=SEX+lDtaJzK3XhO98H9dG3pMe27ipTYTRkmRvQ2x2EchCTZr0aYaDKonsBpV8Nk1dlrr0BlfepcwWHqPrt7ZI5hfLrWUP0z9CYEBhG189r4Y03fqWhQUBV9YVYqGaxuFUZmCcQZPvMUPiVYcEY9VfzuGH9hly0iyec3jCjhnkBU= 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 1760615125224474.3223560073129; Thu, 16 Oct 2025 04:45:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNi-0007Xj-6D; Thu, 16 Oct 2025 07:42:54 -0400 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 1v9MN8-0007Et-Ff; Thu, 16 Oct 2025 07:42:21 -0400 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 1v9MMp-0003WD-EU; Thu, 16 Oct 2025 07:42:13 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 200DEC01BE; Thu, 16 Oct 2025 14:41:38 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-jabrmu5C; Thu, 16 Oct 2025 14:41:37 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614897; bh=4cgovY7tyDau9EmQRY+aKBap0SqRZ3wu+IcsVV5ZIew=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=OrheK5kWODMj9Sm46WDHPjCXdSUUw773g/qtifCblTi3dJZ/aIUb5UrRZCV3YRCRz QAIhycvDA9+Gu9Rop2ssBVP2TwoNAn5o/s7HKFCRs0zah1HSuInZ7xbiYSrNm7dJuf 0UXSFQ6rtSJWL1TYLpNWsU4nTKOppKZoQxdVXJr0= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 19/25] vhost: support backend-transfer migration Date: Thu, 16 Oct 2025 14:40:56 +0300 Message-ID: <20251016114104.1384675-20-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615128287158500 Content-Type: text/plain; charset="utf-8" Introduce vhost_dev.backend_transfer field, Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz --- hw/virtio/vhost.c | 121 +++++++++++++++++++++++++++++++++----- include/hw/virtio/vhost.h | 7 +++ 2 files changed, 113 insertions(+), 15 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 63036f8214..c46203eb9c 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1325,6 +1325,8 @@ out: return ret; } =20 +static void vhost_virtqueue_error_notifier(EventNotifier *n); + int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, @@ -1350,7 +1352,13 @@ int vhost_virtqueue_start(struct vhost_dev *dev, return r; } =20 - vq->num =3D state.num =3D virtio_queue_get_num(vdev, idx); + vq->num =3D virtio_queue_get_num(vdev, idx); + + if (dev->backend_transfer) { + return 0; + } + + state.num =3D vq->num; r =3D dev->vhost_ops->vhost_set_vring_num(dev, &state); if (r) { VHOST_OPS_DEBUG(r, "vhost_set_vring_num failed"); @@ -1428,6 +1436,10 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, =20 trace_vhost_virtque_stop_in(dev, vdev->name, idx); =20 + if (dev->backend_transfer) { + return 0; + } + if (virtio_queue_get_desc_addr(vdev, idx) =3D=3D 0) { /* Don't stop the virtqueue which might have not been started */ return 0; @@ -1565,10 +1577,14 @@ fail_call: =20 static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq) { - event_notifier_cleanup(&vq->masked_notifier); + if (!vq->dev->backend_transfer) { + event_notifier_cleanup(&vq->masked_notifier); + } if (vq->dev->vhost_ops->vhost_set_vring_err) { event_notifier_set_handler(&vq->error_notifier, NULL); - event_notifier_cleanup(&vq->error_notifier); + if (!vq->dev->backend_transfer) { + event_notifier_cleanup(&vq->error_notifier); + } } } =20 @@ -1635,6 +1651,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, =20 hdev->vdev =3D NULL; hdev->migration_blocker =3D NULL; + hdev->_features_wait_incoming =3D true; hdev->busyloop_timeout =3D busyloop_timeout; =20 for (i =3D 0; i < hdev->nvqs; ++i) { @@ -1717,6 +1734,8 @@ int vhost_dev_connect(struct vhost_dev *hdev, Error *= *errp) goto fail; } =20 + hdev->_features_wait_incoming =3D false; + for (i =3D 0; i < hdev->nvqs; ++i, ++n_initialized_vqs) { r =3D vhost_virtqueue_connect(hdev->vqs + i, hdev->vq_index + i); if (r < 0) { @@ -1808,8 +1827,11 @@ void vhost_dev_disable_notifiers_nvqs(struct vhost_d= ev *hdev, */ memory_region_transaction_commit(); =20 - for (i =3D 0; i < nvqs; ++i) { - virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index = + i); + if (!hdev->backend_transfer) { + for (i =3D 0; i < nvqs; ++i) { + virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), + hdev->vq_index + i); + } } virtio_device_release_ioeventfd(vdev); } @@ -1967,6 +1989,11 @@ void vhost_get_features_ex(struct vhost_dev *hdev, { const int *bit =3D feature_bits; =20 + if (hdev->_features_wait_incoming) { + /* Excessive set is enough for early initialization. */ + return; + } + while (*bit !=3D VHOST_INVALID_FEATURE_BIT) { if (!vhost_dev_has_feature_ex(hdev, *bit)) { virtio_clear_feature_ex(features, *bit); @@ -2001,6 +2028,54 @@ const VMStateDescription vmstate_backend_transfer_vh= ost_inflight =3D { } }; =20 +const VMStateDescription vmstate_vhost_virtqueue =3D { + .name =3D "vhost-virtqueue", + .fields =3D (const VMStateField[]) { + VMSTATE_EVENT_NOTIFIER(error_notifier, struct vhost_virtqueue), + VMSTATE_EVENT_NOTIFIER(masked_notifier, struct vhost_virtqueue), + VMSTATE_END_OF_LIST() + }, +}; + +static int vhost_dev_post_load(void *opaque, int version_id) +{ + struct vhost_dev *hdev =3D opaque; + Error *err =3D NULL; + int i; + + if (!check_memslots(hdev, &err)) { + error_report_err(err); + return -EINVAL; + } + + hdev->_features_wait_incoming =3D false; + + if (hdev->vhost_ops->vhost_set_vring_err) { + for (i =3D 0; i < hdev->nvqs; ++i) { + event_notifier_set_handler(&hdev->vqs[i].error_notifier, + vhost_virtqueue_error_notifier); + } + } + + + return 0; +} + +const VMStateDescription vmstate_vhost_dev =3D { + .name =3D "vhost-dev", + .post_load =3D vhost_dev_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(_features, struct vhost_dev), + VMSTATE_UINT64(max_queues, struct vhost_dev), + VMSTATE_UINT32_EQUAL(nvqs, struct vhost_dev, NULL), + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(vqs, struct vhost_dev, + nvqs, + vmstate_vhost_virtqueue, + struct vhost_virtqueue), + VMSTATE_END_OF_LIST() + }, +}; + void vhost_ack_features_ex(struct vhost_dev *hdev, const int *feature_bits, const uint64_t *features) { @@ -2127,19 +2202,24 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIOD= evice *vdev, bool vrings) hdev->started =3D true; hdev->vdev =3D vdev; =20 - r =3D vhost_dev_set_features(hdev, hdev->log_enabled); - if (r < 0) { - goto fail_features; + if (!hdev->backend_transfer) { + r =3D vhost_dev_set_features(hdev, hdev->log_enabled); + if (r < 0) { + warn_report("%s %d", __func__, __LINE__); + goto fail_features; + } } =20 if (vhost_dev_has_iommu(hdev)) { memory_listener_register(&hdev->iommu_listener, vdev->dma_as); } =20 - r =3D hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); - if (r < 0) { - VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); - goto fail_mem; + if (!hdev->backend_transfer) { + r =3D hdev->vhost_ops->vhost_set_mem_table(hdev, hdev->mem); + if (r < 0) { + VHOST_OPS_DEBUG(r, "vhost_set_mem_table failed"); + goto fail_mem; + } } for (i =3D 0; i < hdev->nvqs; ++i) { r =3D vhost_virtqueue_start(hdev, @@ -2179,13 +2259,13 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIOD= evice *vdev, bool vrings) } vhost_dev_elect_mem_logger(hdev, true); } - if (vrings) { + if (vrings && !hdev->backend_transfer) { r =3D vhost_dev_set_vring_enable(hdev, true); if (r) { goto fail_log; } } - if (hdev->vhost_ops->vhost_dev_start) { + if (hdev->vhost_ops->vhost_dev_start && !hdev->backend_transfer) { r =3D hdev->vhost_ops->vhost_dev_start(hdev, true); if (r) { goto fail_start; @@ -2207,6 +2287,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev, bool vrings) } vhost_start_config_intr(hdev); =20 + hdev->backend_transfer =3D false; + trace_vhost_dev_start_out(hdev, vdev->name); return 0; fail_iotlb: @@ -2262,9 +2344,18 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev,= VirtIODevice *vdev, if (hdev->vhost_ops->vhost_dev_start) { hdev->vhost_ops->vhost_dev_start(hdev, false); } - if (vrings) { + if (vrings && !hdev->backend_transfer) { vhost_dev_set_vring_enable(hdev, false); } + + if (hdev->backend_transfer) { + for (i =3D 0; i < hdev->nvqs; ++i) { + struct vhost_virtqueue *vq =3D hdev->vqs + i; + + event_notifier_set_handler(&vq->error_notifier, NULL); + } + } + for (i =3D 0; i < hdev->nvqs; ++i) { rc |=3D do_vhost_virtqueue_stop(hdev, vdev, diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 94a0c75fc8..55ad822848 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -105,6 +105,9 @@ struct vhost_dev { VIRTIO_DECLARE_FEATURES(_features); VIRTIO_DECLARE_FEATURES(acked_features); =20 + bool _features_wait_incoming; + bool backend_transfer; + uint32_t busyloop_timeout; uint64_t max_queues; uint64_t backend_cap; @@ -592,4 +595,8 @@ extern const VMStateDescription vmstate_backend_transfe= r_vhost_inflight; VMSTATE_STRUCT_POINTER(_field, _state, vmstate_inflight, \ struct vhost_inflight) =20 +extern const VMStateDescription vmstate_vhost_dev; +#define VMSTATE_BACKEND_TRANSFER_VHOST(_field, _state) \ + VMSTATE_STRUCT(_field, _state, 0, vmstate_vhost_dev, struct vhost_dev) + #endif --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615174; cv=none; d=zohomail.com; s=zohoarc; b=lyjTeURh8PSudUQ//GPwlH87DAszxhrG7dteE3BcTYlfwtL9E1Oj0Wni2AIpP6hGFA8WHahT/sJ0G/6GqzB+0t5HI8NsFaYd2elxqYbh3bLshFoA5+CjTaZ+f9TaBDXat5TWCk3TRNVXcVkER1eVtfG80ilnF482d+vue2PniWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615174; 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=kdIFXuaPTp/BfbVEZsthEVutCRQg5Y0tS4H8w9udEPE=; b=c72cyMaI92mQi6MBhKBFwKDLYFsQ+xqYelGatmaZVPNPGCh5HZS2QSV1hlF3TS4jGcoHnzoxpY3mUrKVHg0hDtyaVLEJKkSyaCdsgJDw663NGhumtfr1h7dMp40J6yTvZf4PAWRchZKKd+PywESxU6vw+I8xm53gansIzZesAvg= 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 1760615174459896.1030428081808; Thu, 16 Oct 2025 04:46:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNs-0007ko-9e; Thu, 16 Oct 2025 07:43:04 -0400 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 1v9MNF-0007Gw-Ty; Thu, 16 Oct 2025 07:42:30 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MN9-0003WI-6G; Thu, 16 Oct 2025 07:42:24 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id E413DC01E2; Thu, 16 Oct 2025 14:41:38 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-RYmLMXZs; Thu, 16 Oct 2025 14:41:38 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614898; bh=kdIFXuaPTp/BfbVEZsthEVutCRQg5Y0tS4H8w9udEPE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=e2Dxekh174wsHqceWBfHueJM2/cHPGf5UkiSTy8YbRha0/aq5vwelBvKSyfXdaFy2 2ckuhk4l5CLHfTY+CF1LNfTJ8POh0Yi4whMgKNLdvirM4sFEHr84XHjpZGSo6KyeoY 3YH61i/sQNJdG3+GAaRaUVIJchtL9bffsQsEYZKQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 20/25] vhost-user: add vmstate Date: Thu, 16 Oct 2025 14:40:57 +0300 Message-ID: <20251016114104.1384675-21-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615176935154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/virtio/vhost-user.c | 95 ++++++++++++++++++++++++++++++++++ include/hw/virtio/vhost-user.h | 4 ++ 2 files changed, 99 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c5cb5ed528..a820214188 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -28,6 +28,8 @@ #include "system/runstate.h" #include "system/cryptodev.h" #include "migration/postcopy-ram.h" +#include "migration/qemu-file-types.h" +#include "migration/qemu-file.h" #include "trace.h" #include "system/ramblock.h" =20 @@ -3137,6 +3139,99 @@ void vhost_user_qmp_status(struct vhost_dev *dev, Vi= rtioStatus *status) qmp_decode_protocols(u->protocol_features); } =20 +typedef struct VhostUserMigTmp { + struct vhost_dev *parent; + bool has_backend_channel; + int backend_fd; + uint32_t memory_slots; + uint64_t protocol_features; +} VhostUserMigTmp; + +static int vhost_user_tmp_pre_save(void *opaque) +{ + VhostUserMigTmp *tmp =3D opaque; + struct vhost_dev *dev =3D tmp->parent; + struct vhost_user *u =3D dev->opaque; + QIOChannelSocket *sioc =3D u->backend_sioc; + + if (sioc && sioc->fd < 0) { + return -EINVAL; + } + + tmp->backend_fd =3D sioc ? sioc->fd : -1; + tmp->has_backend_channel =3D !!sioc; + tmp->memory_slots =3D u->user->memory_slots; + tmp->protocol_features =3D u->protocol_features; + + return 0; +} + +static int vhost_user_tmp_post_load(void *opaque, int version_id) +{ + struct VhostUserMigTmp *tmp =3D opaque; + struct vhost_dev *dev =3D tmp->parent; + struct vhost_user *u =3D dev->opaque; + Error *local_err =3D NULL; + + if (tmp->has_backend_channel) { + u->backend_sioc =3D qio_channel_socket_new_fd(tmp->backend_fd, + &local_err); + if (!u->backend_sioc) { + error_report_err(local_err); + return -EINVAL; + } + u->backend_src =3D qio_channel_add_watch_source( + QIO_CHANNEL(u->backend_sioc), G_IO_IN | G_IO_HUP, + backend_read, u->dev, NULL, NULL); + } + + u->user->memory_slots =3D tmp->memory_slots; + u->protocol_features =3D tmp->protocol_features; + + return 0; +} + +static bool vhost_user_tmp_test_fd(void *opaque, int version_id) +{ + struct VhostUserMigTmp *tmp =3D opaque; + + return tmp->has_backend_channel; +} + +static const VMStateDescription vmstate_vhost_user_blk_tmp =3D { + .name =3D "vhost-user-blk-tmp", + .pre_save =3D vhost_user_tmp_pre_save, + .post_load =3D vhost_user_tmp_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(protocol_features, VhostUserMigTmp), + VMSTATE_UINT32(memory_slots, VhostUserMigTmp), + VMSTATE_BOOL(has_backend_channel, VhostUserMigTmp), + VMSTATE_FD_TEST(backend_fd, VhostUserMigTmp, vhost_user_tmp_test_f= d), + VMSTATE_END_OF_LIST() + }, +}; + +static int vhost_user_post_load(void *opaque, int version_id) +{ + struct vhost_dev *dev =3D opaque; + struct vhost_user *u =3D dev->opaque; + + u->postcopy_notifier.notify =3D vhost_user_postcopy_notifier; + postcopy_add_notifier(&u->postcopy_notifier); + + return 0; +} + +const VMStateDescription vmstate_vhost_user =3D { + .name =3D "vhost-user", + .post_load =3D vhost_user_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_WITH_TMP(struct vhost_dev, VhostUserMigTmp, + vmstate_vhost_user_blk_tmp), + VMSTATE_END_OF_LIST() + } +}; + const VhostOps user_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_USER, .vhost_backend_init =3D vhost_user_backend_init, diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 36d96296a3..fb89268de2 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -114,4 +114,8 @@ void vhost_user_async_close(DeviceState *d, =20 void vhost_user_qmp_status(struct vhost_dev *dev, VirtioStatus *status); =20 +extern const VMStateDescription vmstate_vhost_user; +#define VMSTATE_BACKEND_TRANSFER_VHOST_USER(_field, _state) \ + VMSTATE_STRUCT(_field, _state, 0, vmstate_vhost_user, struct vhost_dev) + #endif --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615434; cv=none; d=zohomail.com; s=zohoarc; b=oKFJ+e1bdVsQVJSo1fEkvjCD9h7FZrL+yUtUCh2BXMJSlJZam81iaghr+yIWC+PFCqfBtaK2kBtxRbptJk/IjOL36phtz6iuaZD0yuxADjrs1EqJ/tMUCoq1t9TIwbz3PBo1E5c7hupCg55qrtHB0fULgIf95DUGwqW/RKJiiAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615434; 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=hT0GBLbghZ3ll8GWVsJhqMckxe5KaPEjWuD5dmK6b50=; b=k8Mnxxqj3JlqglJGz4LE8Zs10DbOwvGBu+RwZ79MECHNdDPjLhyyLjyNuSuZh/Gk9V/0MHq2kZVteW6QZc6CKAeFTuuOgdymBZOwbnqCGBbuA6/LVIzn+jctwSQBvMpxKCaAJmqjavkyRwUrWJwQ3iLn4bIoKGrnSrz/0P3WQac= 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 1760615434318114.30960263024758; Thu, 16 Oct 2025 04:50:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNu-0007og-7H; Thu, 16 Oct 2025 07:43:06 -0400 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 1v9MNG-0007Gv-TY; Thu, 16 Oct 2025 07:42:30 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MN6-0003WF-KC; Thu, 16 Oct 2025 07:42:24 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id B63BCC01E6; Thu, 16 Oct 2025 14:41:39 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-CYxTHhxP; Thu, 16 Oct 2025 14:41:39 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614899; bh=hT0GBLbghZ3ll8GWVsJhqMckxe5KaPEjWuD5dmK6b50=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=XIgYMJoEfrRleGq7aCD+ipU8x+gSWcNSYiI8zHJ+boaDVQeNfd71eEuHndW8BX6gY q0POpnJD909qm1788FxEg6f97cwZCXIJgMyBq2X7CUJLodUUt1EP8VhQsPHvgo89sf T/Qzocpzorrn6zjNjEndafojUrYURZL+cqD3LfMk= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 21/25] virtio: support vhost backend migration Date: Thu, 16 Oct 2025 14:40:58 +0300 Message-ID: <20251016114104.1384675-22-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615438128154100 Content-Type: text/plain; charset="utf-8" Add logic to transfer virtio notifiers through migration channel for vhost backend migration case. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz --- hw/virtio/virtio-bus.c | 2 +- hw/virtio/virtio.c | 73 ++++++++++++++++++++++++++++++++++++-- include/hw/virtio/virtio.h | 2 ++ 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 9b545acda3..577693b6c9 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -291,7 +291,7 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, i= nt n, bool assign) return -ENOSYS; } =20 - if (assign) { + if (assign && !virtio_is_vhost_backend_transfer(vdev)) { r =3D event_notifier_init(notifier, 1); if (r < 0) { error_report("%s: unable to init event notifier: %s (%d)", diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 4184aff75c..bf361811d0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -26,6 +26,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "migration/qemu-file-types.h" +#include "migration/qemu-file.h" #include "qemu/atomic.h" #include "hw/virtio/virtio-bus.h" #include "hw/qdev-properties.h" @@ -3032,6 +3033,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) uint32_t guest_features_lo =3D (vdev->guest_features & 0xffffffff); int i; Error *local_err =3D NULL; + bool migrating_backend =3D virtio_is_vhost_backend_transfer(vdev); =20 if (k->save_config) { k->save_config(qbus->parent, f); @@ -3065,11 +3067,23 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) */ qemu_put_be64(f, vdev->vq[i].vring.desc); qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); + + if (migrating_backend) { + qemu_file_put_fd(f, + event_notifier_get_fd(&vdev->vq[i].host_notif= ier)); + qemu_file_put_fd( + f, event_notifier_get_fd(&vdev->vq[i].guest_notifier)); + } + if (k->save_queue) { k->save_queue(qbus->parent, i, f); } } =20 + if (migrating_backend) { + qemu_file_put_fd(f, event_notifier_get_fd(&vdev->config_notifier)); + } + if (vdc->save !=3D NULL) { vdc->save(vdev, f); } @@ -3295,6 +3309,7 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); Error *local_err =3D NULL; + bool migrating_backend =3D virtio_is_vhost_backend_transfer(vdev); =20 /* * We poison the endianness to ensure it does not get used before @@ -3364,6 +3379,13 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) vdev->vq[i].signalled_used_valid =3D false; vdev->vq[i].notification =3D true; =20 + if (migrating_backend) { + event_notifier_init_fd(&vdev->vq[i].host_notifier, + qemu_file_get_fd(f)); + event_notifier_init_fd(&vdev->vq[i].guest_notifier, + qemu_file_get_fd(f)); + } + if (!vdev->vq[i].vring.desc && vdev->vq[i].last_avail_idx) { error_report("VQ %d address 0x0 " "inconsistent with Host index 0x%x", @@ -3377,6 +3399,10 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) } } =20 + if (migrating_backend) { + event_notifier_init_fd(&vdev->config_notifier, qemu_file_get_fd(f)= ); + } + virtio_notify_vector(vdev, VIRTIO_NO_VECTOR); =20 if (vdc->load !=3D NULL) { @@ -3394,6 +3420,19 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) } } =20 + if (migrating_backend) { + /* + * On vhost backend migration, device do load host_features from + * migration stream. So update host_features. + */ + vdev->host_features =3D vdc->get_features(vdev, vdev->host_feature= s, + &local_err); + if (local_err) { + error_report_err(local_err); + return -EINVAL; + } + } + /* Subsections */ ret =3D vmstate_load_state(f, &vmstate_virtio, vdev, 1, &local_err); if (ret) { @@ -3447,6 +3486,18 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) continue; } =20 + if (migrating_backend) { + /* + * Indices are not synced prior to backend migration (as we + * don't stop vrings by GET_VRING_BASE). No reason to sync= them + * now, and do any checks. + */ + vdev->vq[i].used_idx =3D 0; + vdev->vq[i].shadow_avail_idx =3D 0; + vdev->vq[i].inuse =3D 0; + continue; + } + nheads =3D vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_av= ail_idx; /* Check it isn't doing strange things with descriptor numbers= . */ if (nheads > vdev->vq[i].vring.num) { @@ -3815,8 +3866,9 @@ int virtio_queue_set_guest_notifier(VirtIODevice *vde= v, int n, bool assign, EventNotifierHandler *read_fn =3D is_config ? virtio_config_guest_notifier_read : virtio_queue_guest_notifier_read; + bool migrating_backend =3D virtio_is_vhost_backend_transfer(vdev); =20 - if (assign) { + if (assign && !migrating_backend) { int r =3D event_notifier_init(notifier, 0); if (r < 0) { return r; @@ -3826,7 +3878,7 @@ int virtio_queue_set_guest_notifier(VirtIODevice *vde= v, int n, bool assign, event_notifier_set_handler(notifier, (assign && !with_irqfd) ? read_fn : NULL); =20 - if (!assign) { + if (!assign && !migrating_backend) { /* Test and clear notifier before closing it,*/ /* in case poll callback didn't have time to run. */ read_fn(notifier); @@ -4445,6 +4497,23 @@ done: return element; } =20 +bool virtio_is_vhost_backend_transfer(VirtIODevice *vdev) +{ + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev; + + if (!vdc->get_vhost) { + return false; + } + + hdev =3D vdc->get_vhost(vdev); + if (!hdev) { + return false; + } + + return hdev->backend_transfer; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 620ee4e389..8e2d3019cd 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -242,6 +242,8 @@ struct VirtioDeviceClass { bool (*skip_vhost_migration_log)(VirtIODevice *vdev); }; =20 +bool virtio_is_vhost_backend_transfer(VirtIODevice *vdev); + void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615025; cv=none; d=zohomail.com; s=zohoarc; b=dygzTGC/3rEM14+kQJNrtElAfAL/HCySlpTQ3gSGxCzei3/Ns+32e70Zi2y6dLRNd2T2dSibdTC44coppOjoJTDoogc8rIoxXE1jDsHtmr+pnFPShyFLXBcoCNCWd4GHxFUQcVgkypAdAKj8JbzFuX3Zg3/bnkQz9kLmOQMb4RQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615025; 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=DopEG5rnw7C35mwTWhukVX+E7KE89dHOlir85KGAMEs=; b=edFYOlq+kUlE+eZuMk/j9r070w1KXT0ghJkNt+P/Yxt+4K0F7gN3RldjMIEqoIEIGUepH84fsHFTKntdv036lTV11lhQc317Io/Fu+sYD77+QmSSTVyoyZ5DEZUvGqG/QIkfNNsr6NtZ/eeuKgvS4QLx7K00gyD4sHDcYd1ZWS4= 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 1760615025589232.24601517999508; Thu, 16 Oct 2025 04:43:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNj-0007Zg-S8; Thu, 16 Oct 2025 07:42:55 -0400 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 1v9MN4-0007Cf-M3; Thu, 16 Oct 2025 07:42:16 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMm-0003WE-8I; Thu, 16 Oct 2025 07:42:10 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 644B2C01E4; Thu, 16 Oct 2025 14:41:40 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-Uup5hSoq; Thu, 16 Oct 2025 14:41: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=1760614900; bh=DopEG5rnw7C35mwTWhukVX+E7KE89dHOlir85KGAMEs=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Snmby6Y+VlNDNSzXn7CzHJGJEVD6jMcHHkTN2BrhvnEAX2Q56jWpJLfeIJa0EgMUg 6sRzM+hoz7Yf6tw8wJK6HJ/WOuGVmkd2kXl7h/hPC8gqSI5kFLMWDa5MT17qY6XhXl /NFDniAgC3ubjGjpnDhUUeUKdiXU06Y5OhI3tJLY= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 22/25] virtio: support .needed for virtio vmsd Date: Thu, 16 Oct 2025 14:40:59 +0300 Message-ID: <20251016114104.1384675-23-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615027364154100 Content-Type: text/plain; charset="utf-8" Virtio devices now don't use .needed field for their VMSD, but we are going to use it for vhost-user-blk. So, let's handle this field in generic code. Nothing is changed for existing vmstates. Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index bf361811d0..aa36438e69 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3088,7 +3088,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) vdc->save(vdev, f); } =20 - if (vdc->vmsd) { + if (vdc->vmsd && vmstate_section_needed(vdc->vmsd, vdev)) { int ret =3D vmstate_save_state(f, vdc->vmsd, vdev, NULL, &local_er= r); if (ret) { error_report_err(local_err); @@ -3412,7 +3412,7 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) } } =20 - if (vdc->vmsd) { + if (vdc->vmsd && vmstate_section_needed(vdc->vmsd, vdev)) { ret =3D vmstate_load_state(f, vdc->vmsd, vdev, version_id, &local_= err); if (ret) { error_report_err(local_err); --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615125; cv=none; d=zohomail.com; s=zohoarc; b=UFFi7jqZ+sGy+wz+HR5WC+zlzMM3Q+HybYiQdmINACu9gY+OzqCKCPuNPyyt2sxE9xBwhfyuAFB00RX+LfudlzH572thvjNiC6mDy+fI65F5e7h2cC513lEtJDID1Qp6CBL1L0VMUHtS643WtaXgGfQ1wuxMAlJdzc2SeOl0GwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615125; 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=etGolHGsB6Q4bwretmKOtTv/P9Q70AzAWgYe4IY9dEc=; b=nBsc2l/L8MshKjgYPg84yN1vtQTg1qGgKyQ7G6VBbCvkedNXuHKciY4ECYNJ+TdAWsO5mzPv7TR/KyzCzNtPJsiXDbe4b4qzkzo5aT/9WdrlhlyDrRTFh7DvmWTxB0uZtopNYyjPpKqQ62GWb/UE2JOxeAk+QjeyIsuwR5TqlZU= 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 1760615125278399.72603251004944; Thu, 16 Oct 2025 04:45:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNe-0007VS-Do; Thu, 16 Oct 2025 07:42:50 -0400 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 1v9MNM-0007J4-Cj; Thu, 16 Oct 2025 07:42:34 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MNA-0003WJ-45; Thu, 16 Oct 2025 07:42:29 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 21DA6C01E5; Thu, 16 Oct 2025 14:41:41 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-dX3pXnq5; Thu, 16 Oct 2025 14:41: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=1760614900; bh=etGolHGsB6Q4bwretmKOtTv/P9Q70AzAWgYe4IY9dEc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Ms/zZEb6gxKqik1zu39OiRmEq8tuZCp1kVs+JvQ3m9IdL1FpWCETOw3C9D3i5dHC2 xXpKQuOqG7e1cX3VhO0S8/1FJ8nldOV9a6SfAG/OmAKd6MKj8Yj9mxVpnSl+LfOgbn vtGZV1Rg8BQLVBv97P2WeN0xKpe1Auyo/M3VwUmk= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com, Peter Xu Subject: [PATCH v2 23/25] RFC qapi: add local-vhost-user-blk migration capability Date: Thu, 16 Oct 2025 14:41:00 +0300 Message-ID: <20251016114104.1384675-24-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615126358154100 Content-Type: text/plain; charset="utf-8" That's an old way to enable backend-transfer feature for vhost-user-blk. I just kept it unchanged since v1 of the series. At least, it should be migration-parameter instead of capability. But currently, there is discussion on final API in context of "[PATCH v8 00/19] virtio-net: live-TAP local migration", here: https://lore.kernel.org/qemu-devel/29aa1d66-9fa7-4e44-b0e3-2ca26e77accf@yan= dex-team.ru/ So, consider this one as temporary patch, which will be replaced by some other API. Signed-off-by: Vladimir Sementsov-Ogievskiy --- migration/options.c | 7 +++++++ migration/options.h | 1 + qapi/migration.json | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/migration/options.c b/migration/options.c index 5183112775..3a013b9898 100644 --- a/migration/options.c +++ b/migration/options.c @@ -262,6 +262,13 @@ bool migrate_mapped_ram(void) return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM]; } =20 +bool migrate_local_vhost_user_blk(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->capabilities[MIGRATION_CAPABILITY_LOCAL_VHOST_USER_BLK]; +} + bool migrate_ignore_shared(void) { MigrationState *s =3D migrate_get_current(); diff --git a/migration/options.h b/migration/options.h index 82d839709e..95a3f482bc 100644 --- a/migration/options.h +++ b/migration/options.h @@ -30,6 +30,7 @@ bool migrate_colo(void); bool migrate_dirty_bitmaps(void); bool migrate_events(void); bool migrate_mapped_ram(void); +bool migrate_local_vhost_user_blk(void); bool migrate_ignore_shared(void); bool migrate_late_block_activate(void); bool migrate_multifd(void); diff --git a/qapi/migration.json b/qapi/migration.json index be0f3fcc12..d29a4915b4 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -517,9 +517,15 @@ # each RAM page. Requires a migration URI that supports seeking, # such as a file. (since 9.0) # +# @local-vhost-user-blk: Migrate vhost-user-blk locally, keeping +# backend alive. Open file descriptors and backend-related state +# are migrated. Only may be used when migration channel is UNIX +# domain socket. (since 10.2) +# # Features: # -# @unstable: Members @x-colo and @x-ignore-shared are experimental. +# @unstable: Members @x-colo, @x-ignore-shared, +# @local-vhost-user-blk are experimental. # @deprecated: Member @zero-blocks is deprecated as being part of # block migration which was already removed. # @@ -536,7 +542,8 @@ { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, 'validate-uuid', 'background-snapshot', 'zero-copy-send', 'postcopy-preempt', 'switchover-ack', - 'dirty-limit', 'mapped-ram'] } + 'dirty-limit', 'mapped-ram', + { 'name': 'local-vhost-user-blk', 'features': [ 'unstable' ] } = ] } =20 ## # @MigrationCapabilityStatus: --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615273; cv=none; d=zohomail.com; s=zohoarc; b=Ko0kw70u+lki6a7YSK92+/RXG4+5ixAy8820+J3ibINgRbUsjjHcpqc4H1K+OiDUOI/lE4qmmctb9+QPXNo/h9uTPO1ulLeGR+Ikb0ARlBJWT6obzFEwwDHX2cyrS5D4j1FgUJ2rS9CY48Pf4Ngne7Ss+84ApvW6NGnOKdf8aIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615273; 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=FQa5UwKvUo2fp+LZPlQdGfhHVLkM6RfOrSZz/WATnZE=; b=SFzt90d8MADHtsLZ8bsxA0N+hP3FrIaxmvC520u5jSxYTx12G405pou6UrLEo/H+Wxtt6Q7ZYqfI0X8rWh/oXaer0xXdhWjKO8RoUIsFFB/VZa2q+GCxUKQELqCMKLZ9oEMTAyZnAUcWk5ZNtT0rAx4cj6lAZszI4rPEC5xmH6k= 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 1760615272895255.23677950673016; Thu, 16 Oct 2025 04:47:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNf-0007WL-99; Thu, 16 Oct 2025 07:42:51 -0400 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 1v9MNO-0007JQ-Ew; Thu, 16 Oct 2025 07:42:37 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MNA-0003Wa-RW; Thu, 16 Oct 2025 07:42:32 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 0C04EC01C7; Thu, 16 Oct 2025 14:41:42 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-bUjaRCUF; Thu, 16 Oct 2025 14:41: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=1760614901; bh=FQa5UwKvUo2fp+LZPlQdGfhHVLkM6RfOrSZz/WATnZE=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=bKsCtGNDsy2GQ5rtZH+POpEx6fc2lSDcX+oeGoWhgLAKmilMVIyj59UOnpH7ezMfm u7J10LBBDQEYhdDIKsOLrArWqZ1+Gmh0Pnr2IkfTHebSVc0CYL8sX1Hljt5gdi+WXj fYIWtDqkC6JwqOKCMzbS8rpFGnSqBY+FjzB/gzsE= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 24/25] vhost-user-blk: support vhost backend migration Date: Thu, 16 Oct 2025 14:41:01 +0300 Message-ID: <20251016114104.1384675-25-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1760615304699154100 Content-Type: text/plain; charset="utf-8" Opt-out backend initialization code, and instead get the state from migration channel (including inflight region). Signed-off-by: Vladimir Sementsov-Ogievskiy --- hw/block/vhost-user-blk.c | 129 ++++++++++++++++++++++++----- include/hw/virtio/vhost-user-blk.h | 2 + include/hw/virtio/vhost.h | 3 +- 3 files changed, 111 insertions(+), 23 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index ffdd600526..a8fd90480a 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -17,6 +17,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi-types-run-state.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/cutils.h" @@ -31,7 +32,13 @@ #include "hw/virtio/virtio-access.h" #include "system/system.h" #include "system/runstate.h" +#include "chardev/char-backend-transfer.h" #include "trace.h" +#include "migration/qemu-file.h" +#include "migration/migration.h" +#include "migration/options.h" +#include "qemu/event_notifier.h" +#include =20 static const int user_feature_bits[] =3D { VIRTIO_BLK_F_SIZE_MAX, @@ -160,32 +167,35 @@ static int vhost_user_blk_start(VirtIODevice *vdev, E= rror **errp) =20 s->dev.acked_features =3D vdev->guest_features; =20 - ret =3D vhost_dev_prepare_inflight(&s->dev, vdev); - if (ret < 0) { - error_setg_errno(errp, -ret, "Error setting inflight format"); - goto err_guest_notifiers; - } - - if (!s->inflight->addr) { - ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); + if (!s->dev.backend_transfer) { + ret =3D vhost_dev_prepare_inflight(&s->dev, vdev); if (ret < 0) { - error_setg_errno(errp, -ret, "Error getting inflight"); + error_setg_errno(errp, -ret, "Error setting inflight format"); goto err_guest_notifiers; } - } =20 - ret =3D vhost_dev_set_inflight(&s->dev, s->inflight); - if (ret < 0) { - error_setg_errno(errp, -ret, "Error setting inflight"); - goto err_guest_notifiers; - } + if (!s->inflight->addr) { + ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->infl= ight); + if (ret < 0) { + error_setg_errno(errp, -ret, "Error getting inflight"); + goto err_guest_notifiers; + } + } =20 - /* guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i =3D 0; i < s->dev.nvqs; i++) { - vhost_virtqueue_mask(&s->dev, vdev, i, false); + ret =3D vhost_dev_set_inflight(&s->dev, s->inflight); + if (ret < 0) { + error_setg_errno(errp, -ret, "Error setting inflight"); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < s->dev.nvqs; i++) { + vhost_virtqueue_mask(&s->dev, vdev, i, false); + } } =20 s->dev.vq_index_end =3D s->dev.nvqs; @@ -232,6 +242,10 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 + s->dev.backend_transfer =3D s->dev.backend_transfer || + (runstate_check(RUN_STATE_FINISH_MIGRATE) && + migrate_local_vhost_user_blk()); + ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : vhost_dev_stop(&s->dev, vdev, true); =20 @@ -391,6 +405,7 @@ static int vhost_user_blk_connect(DeviceState *dev, trace_vhost_user_blk_connect_in(vdev); =20 assert(!s->connected); + assert(!s->dev.backend_transfer); =20 ret =3D vhost_dev_connect(&s->dev, errp); if (ret < 0) { @@ -464,6 +479,9 @@ static int vhost_user_blk_realize_connect(VHostUserBlk = *s, Error **errp) DeviceState *dev =3D DEVICE(s); int ret; =20 + assert(!s->connected); + assert(!s->dev.backend_transfer); + ret =3D qemu_chr_fe_wait_connected(&s->chardev, errp); if (ret < 0) { return ret; @@ -642,7 +660,13 @@ static bool vhost_user_blk_pre_incoming(void *opaque, = Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(opaque); =20 - return vhost_user_blk_realize_connect(s, errp) =3D=3D 0; + s->dev.backend_transfer =3D migrate_local_vhost_user_blk(); + + if (!s->dev.backend_transfer) { + return vhost_user_blk_realize_connect_loop(s, errp) >=3D 0; + } + + return true; } =20 static const VMStateDescription vmstate_vhost_user_blk =3D { @@ -656,6 +680,64 @@ static const VMStateDescription vmstate_vhost_user_blk= =3D { }, }; =20 +static bool vhost_user_needed(void *opaque) +{ + return migrate_local_vhost_user_blk(); +} + +static const VMStateDescription vmstate_vhost_user_blk_device =3D { + .name =3D "vhost-user-blk-device", + .version_id =3D 1, + .needed =3D vhost_user_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_BACKEND_TRANSFER_CHARDEV(chardev, VHostUserBlk), + VMSTATE_BACKEND_TRANSFER_VHOST_INFLIGHT(inflight, VHostUserBlk), + VMSTATE_BACKEND_TRANSFER_VHOST_USER(dev, VHostUserBlk), + VMSTATE_BACKEND_TRANSFER_VHOST(dev, VHostUserBlk), + VMSTATE_END_OF_LIST() + }, +}; + +static int vhost_user_blk_post_load(VirtIODevice *vdev) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + struct vhost_dev *hdev =3D vhost_user_blk_get_vhost(vdev); + DeviceState *dev =3D &s->parent_obj.parent_obj; + + if (!hdev->backend_transfer) { + return 0; + } + + s->connected =3D true; + + memcpy(&s->blkcfg, vdev->config, vdev->config_len); + + if (virtio_device_started(vdev, vdev->status)) { + int ret; + ret =3D vhost_user_blk_start(vdev, NULL); + if (ret < 0) { + return ret; + } + } + + /* we're fully initialized, now we can operate, so add the handler */ + qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, + vhost_user_blk_event, NULL, (void *)dev, + NULL, true); + + return 0; +} + +static bool vhost_user_blk_skip_migration_log(VirtIODevice *vdev) +{ + /* + * Note that hdev->migrating_backend is false at this moment, + * as logging is being setup during outging migration setup stage, + * which is far before vm stop. + */ + return migrate_local_vhost_user_blk(); +} + static const Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR_NO_CONNECT("chardev", VHostUserBlk, chardev), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, @@ -688,6 +770,9 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, const void *data) vdc->set_status =3D vhost_user_blk_set_status; vdc->reset =3D vhost_user_blk_reset; vdc->get_vhost =3D vhost_user_blk_get_vhost; + vdc->vmsd =3D &vmstate_vhost_user_blk_device; + vdc->post_load =3D vhost_user_blk_post_load, + vdc->skip_vhost_migration_log =3D vhost_user_blk_skip_migration_log; } =20 static const TypeInfo vhost_user_blk_info =3D { diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index a10f785672..b06f55fd6f 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -52,6 +52,8 @@ struct VHostUserBlk { bool started_vu; =20 bool skip_get_vring_base_on_force_shutdown; + + bool incoming_backend; }; =20 #endif diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 55ad822848..13ca2c319f 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -592,7 +592,8 @@ static inline int vhost_load_backend_state(struct vhost= _dev *dev, QEMUFile *f, =20 extern const VMStateDescription vmstate_backend_transfer_vhost_inflight; #define VMSTATE_BACKEND_TRANSFER_VHOST_INFLIGHT(_field, _state) \ - VMSTATE_STRUCT_POINTER(_field, _state, vmstate_inflight, \ + VMSTATE_STRUCT_POINTER(_field, _state, \ + vmstate_backend_transfer_vhost_inflight, \ struct vhost_inflight) =20 extern const VMStateDescription vmstate_vhost_dev; --=20 2.48.1 From nobody Fri Nov 14 18:23:11 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=1760615366; cv=none; d=zohomail.com; s=zohoarc; b=EAC9NIIIljJs2ss8OTfiQs54zBUaG93Ke0bVxGSKiWaA4zvYWaies8RUXkL/u0odmzXH33hKfiein0tdesOiN1SgVllmR70fqJzEFpJQy9RC5mZ2/Kx7dMaF8XENk8W26jUvbAleSXP4yi2ffJX/4beU8Zt6SXL4Yifo9jJ2oLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615366; 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=HFE8QjC8Rnlm0okx70mpoOdoiRgantXWnrfbocdxBfk=; b=d4uHH3aP4NE5n8iSuQ3OunXLxMFyBJuY8WR12vbsHqtXLrg66GkGSnvB3Zcgd43jW9YmKSI7JIsfSWXFqAcTHRIHEe3AQVZEL4cGIL2srZsZbZsLav3LWAaHSJNEZyQGn28UJ0ncmva93h31JcyAhvkKduGdXlAJR+040tTyUr4= 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 1760615366031668.1884414015091; Thu, 16 Oct 2025 04:49:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNf-0007WI-A7; Thu, 16 Oct 2025 07:42:51 -0400 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 1v9MN0-0007B8-52; Thu, 16 Oct 2025 07:42:14 -0400 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 1v9MMt-0003Wb-ER; Thu, 16 Oct 2025 07:42:07 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 5E24BC01E8; Thu, 16 Oct 2025 14:41:43 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-j6aB0vES; Thu, 16 Oct 2025 14:41:42 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614902; bh=HFE8QjC8Rnlm0okx70mpoOdoiRgantXWnrfbocdxBfk=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=VESwroG5eUtyHBICBfrKSGq1v/Rn3VzMJ/Pp3J6IPMXgIaOi+1wk74VRaDGHio6FQ QxsMo4VjTPaTLrSZdkCfKFbQhks+uWPIjSwEpyTA3VWk4o7rt0prp/ipJuiltADLE4 abzylGXg0AXjCKTLzHF+rm0SgdMh6B3aS14vSjbY= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 25/25] tests/functional: add test_x86_64_vhost_user_blk_fd_migration.py Date: Thu, 16 Oct 2025 14:41:02 +0300 Message-ID: <20251016114104.1384675-26-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@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.72; envelope-from=vsementsov@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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 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: 1760615369295158500 Content-Type: text/plain; charset="utf-8" Introduce a simple test to check that local migration of vhost-user-blk device with passing open fds through unix socket works, and the disk is still working on target. Signed-off-by: Vladimir Sementsov-Ogievskiy --- ...test_x86_64_vhost_user_blk_fd_migration.py | 307 ++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 tests/functional/test_x86_64_vhost_user_blk_fd_migratio= n.py diff --git a/tests/functional/test_x86_64_vhost_user_blk_fd_migration.py b/= tests/functional/test_x86_64_vhost_user_blk_fd_migration.py new file mode 100644 index 0000000000..0523a71f15 --- /dev/null +++ b/tests/functional/test_x86_64_vhost_user_blk_fd_migration.py @@ -0,0 +1,307 @@ +#!/usr/bin/env python3 +# +# Functional test that tests vhost-user-blk local migration +# with fd passing +# +# Copyright (c) Yandex +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import time +import subprocess + +from qemu_test import ( + LinuxKernelTest, + Asset, + exec_command_and_wait_for_pattern, +) + + +def wait_migration_finish(source_vm, target_vm): + migr_events =3D ( + ("MIGRATION", {"data": {"status": "completed"}}), + ("MIGRATION", {"data": {"status": "failed"}}), + ) + + source_e =3D source_vm.events_wait(migr_events)["data"] + target_e =3D target_vm.events_wait(migr_events)["data"] + + source_s =3D source_vm.cmd("query-status")["status"] + target_s =3D target_vm.cmd("query-status")["status"] + + assert ( + source_e["status"] =3D=3D "completed" + and target_e["status"] =3D=3D "completed" + and source_s =3D=3D "postmigrate" + and target_s =3D=3D "paused" + ), f"""Migration failed: + SRC status: {source_s} + SRC event: {source_e} + TGT status: {target_s} + TGT event:{target_e}""" + + +class VhostUserBlkFdMigration(LinuxKernelTest): + + ASSET_KERNEL =3D Asset( + ( + "https://archives.fedoraproject.org/" + "pub/archive/fedora/linux/releases" + "/31/Server/x86_64/os/images/pxeboot/vmlinuz" + ), + "d4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129", + ) + + ASSET_INITRD =3D Asset( + ( + "https://archives.fedoraproject.org/" + "pub/archive/fedora/linux/releases" + "/31/Server/x86_64/os/images/pxeboot/initrd.img" + ), + "277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b", + ) + + DATA1 =3D "TEST_DATA_BEFORE_MIGRATION_12345" + DATA2 =3D "TEST_DATA_AFTER_MIGRATION_54321" + + def write_data(self, data, vm) -> None: + exec_command_and_wait_for_pattern( + self, + f'echo "{data}" | ' "dd of=3D/dev/vda bs=3D512 count=3D1 oflag= =3Ddirect", + "# ", + vm=3Dvm, + ) + + def read_data(self, data, vm) -> None: + exec_command_and_wait_for_pattern( + self, + "dd if=3D/dev/vda bs=3D512 count=3D1 iflag=3Ddirect 2>/dev/nul= l", + data, + vm=3Dvm, + ) + + def setUp(self): + super().setUp() + self.vhost_procs =3D [] + + def tearDown(self): + # Cleanup vhost-user server processes + for proc in self.vhost_procs: + if proc: + try: + proc.terminate() + proc.wait(timeout=3D5) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait() + except: + pass + + super().tearDown() + + def create_test_image(self): + """Create a temporary test image for vhost-user-blk""" + img_path =3D self.scratch_file("disk.img") + + # Create 64MB image + with open(img_path, "wb") as f: + f.write(b"\0" * (64 * 1024 * 1024)) + + return img_path + + def start_vhost_user_server(self, socket_path, img_path): + """Start vhost-user-blk server using contrib/vhost-user-blk""" + # Find vhost-user-blk binary + vub_binary =3D self.build_file( + "contrib", "vhost-user-blk", "vhost-user-blk" + ) + + if not os.path.isfile(vub_binary) or not os.access(vub_binary, os.= X_OK): + self.skipTest("vhost-user-blk binary not found") + + # assert that our further waiting would be correct + self.assertFalse(os.path.exists(socket_path)) + + cmd =3D [vub_binary, "-s", socket_path, "-b", img_path] + self.log.info(f'Starting vhost-user server: {" ".join(cmd)}') + proc =3D subprocess.Popen( + cmd, stderr=3Dsubprocess.PIPE, text=3DTrue, preexec_fn=3Dos.se= tsid + ) + self.vhost_procs.append(proc) + + # Wait for socket to be created + for _ in range(100): # 10 seconds timeout + time.sleep(0.1) + + # Check if process is still running + if proc.poll() is not None: + self.fail(f"vhost-user server failed: {proc.stderr}") + + if os.path.exists(socket_path): + return + + self.fail(f"vhost-user socket {socket_path} was not created") + + def setup_shared_memory(self): + shm_path =3D f"/dev/shm/qemu_test_{os.getpid()}" + + try: + with open(shm_path, "wb") as f: + f.write(b"\0" * (1024 * 1024 * 1024)) # 1GB + except Exception as e: + self.fail(f"Failed to create shared memory file: {e}") + + return shm_path + + def prepare_and_launch_vm( + self, + shm_path, + vhost_socket, + incoming=3DFalse, + vm=3DNone, + use_backend_transfer=3DTrue, + ): + if not vm: + vm =3D self.vm + + vm.add_args("-accel", "kvm") + vm.add_args("-device", "pcie-pci-bridge,id=3Dpci.1,bus=3Dpcie.0") + vm.add_args("-m", "1G") + vm.add_args("-append", "console=3DttyS0 rd.rescue") + + vm.add_args( + "-object", + f"memory-backend-file,id=3Dram0,size=3D1G,mem-path=3D{shm_path= },share=3Don", + ) + vm.add_args("-machine", "memory-backend=3Dram0") + + vm.add_args("-kernel", self.ASSET_KERNEL.fetch()) + vm.add_args("-initrd", self.ASSET_INITRD.fetch()) + + vm.add_args("-S") + + if incoming: + vm.add_args("-incoming", "defer") + + vm.set_console() + + vm_s =3D "target" if incoming else "source" + self.log.info(f"Launching {vm_s} VM") + vm.launch() + + self.set_migration_capabilities(vm, use_backend_transfer) + self.add_vhost_user_blk_device(vm, vhost_socket) + + def add_vhost_user_blk_device(self, vm, socket_path): + # Add chardev + chardev_params =3D { + "id": "chardev-virtio-disk0", + "backend": { + "type": "socket", + "data": { + "addr": {"type": "unix", "data": {"path": socket_path}= }, + "server": False, + "reconnect-ms": 20, + }, + }, + } + + vm.cmd("chardev-add", chardev_params) + + # Add device + device_params =3D { + "id": "virtio-disk0", + "driver": "vhost-user-blk-pci", + "chardev": "chardev-virtio-disk0", + "num-queues": 1, + "bus": "pci.1", + "config-wce": False, + "bootindex": 1, + "disable-legacy": "off", + } + + vm.cmd("device_add", device_params) + + def set_migration_capabilities(self, vm, use_backend_transfer=3DTrue): + capabilities =3D [ + {"capability": "events", "state": True}, + {"capability": "x-ignore-shared", "state": True}, + ] + + if use_backend_transfer: + capabilities.append( + {"capability": "local-vhost-user-blk", "state": True} + ) + + vm.cmd("migrate-set-capabilities", {"capabilities": capabilities}) + + def do_test_vhost_user_blk_fd_migration(self, use_backend_transfer=3DT= rue): + self.require_accelerator("kvm") + self.set_machine("q35") + + socket_dir =3D self.socket_dir() + vhost_socket =3D os.path.join(socket_dir.name, "vhost-user-blk.soc= k") + migration_socket =3D os.path.join(socket_dir.name, "migration.sock= ") + + img_path =3D self.create_test_image() + shm_path =3D self.setup_shared_memory() + + self.start_vhost_user_server(vhost_socket, img_path) + + if not use_backend_transfer: + target_vhost_socket =3D os.path.join( + socket_dir.name, "vhost-user-blk-target.sock" + ) + self.start_vhost_user_server(target_vhost_socket, img_path) + else: + target_vhost_socket =3D vhost_socket + + self.prepare_and_launch_vm( + shm_path, vhost_socket, use_backend_transfer=3Duse_backend_tra= nsfer + ) + self.vm.cmd("cont") + self.wait_for_console_pattern("Entering emergency mode.") + self.wait_for_console_pattern("# ") + + self.write_data(self.DATA1, self.vm) + self.read_data(self.DATA1, self.vm) + + target_vm =3D self.get_vm(name=3D"target") + self.prepare_and_launch_vm( + shm_path, + target_vhost_socket, + incoming=3DTrue, + vm=3Dtarget_vm, + use_backend_transfer=3Duse_backend_transfer, + ) + + target_vm.cmd("migrate-incoming", {"uri": f"unix:{migration_socket= }"}) + + self.log.info("Starting migration") + self.vm.cmd("migrate", {"uri": f"unix:{migration_socket}"}) + + self.log.info("Waiting for migration completion") + wait_migration_finish(self.vm, target_vm) + + target_vm.cmd("cont") + self.vm.shutdown() + + self.log.info("Verifying disk on target VM after migration") + self.read_data(self.DATA1, target_vm) + self.write_data(self.DATA2, target_vm) + self.read_data(self.DATA2, target_vm) + + target_vm.shutdown() + + def test_vhost_user_blk_fd_migration_backend_transfer(self): + """Test vhost-user-blk migration with backend-transfer (fd passing= )""" + self.do_test_vhost_user_blk_fd_migration(use_backend_transfer=3DTr= ue) + + def test_vhost_user_blk_fd_migration_regular(self): + """Test vhost-user-blk migration without backend-transfer""" + self.do_test_vhost_user_blk_fd_migration(use_backend_transfer=3DFa= lse) + + +if __name__ =3D=3D "__main__": + LinuxKernelTest.main() --=20 2.48.1