From nobody Sun May 19 13:07:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691651279877493.57267479897257; Thu, 10 Aug 2023 00:07:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTzlL-0005Oe-WA; Thu, 10 Aug 2023 03:07:16 -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 1qTzlJ-0005No-NV for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:13 -0400 Received: from mail-b.sr.ht ([173.195.146.151]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTzlH-0004oH-TS for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:13 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 1A20B11EF15; Thu, 10 Aug 2023 07:07:10 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=none From: ~hyman Date: Sat, 05 Aug 2023 10:33:21 +0800 Subject: [PATCH QEMU v2 1/3] virtio-scsi-pci: introduce auto-num-queues property MIME-Version: 1.0 Message-ID: <169165122958.4096.6557269987206106594-1@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <169165122958.4096.6557269987206106594-0@git.sr.ht> To: qemu-devel Cc: Raphael Norwitz , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng , yong.huang@smartx.com Content-Type: text/plain; charset="utf-8" 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=173.195.146.151; envelope-from=outgoing@sr.ht; helo=mail-b.sr.ht X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1691651282066100009 From: Hyman Huang(=E9=BB=84=E5=8B=87) Commit "6a55882284 virtio-scsi-pci: default num_queues to -smp N" implment sizing the number of virtio-scsi-pci request virtqueues to match the number of vCPUs automatically. Which improves IO preformance remarkably. To enable this feature for the existing VMs, the cloud platform may migrate VMs from the source hypervisor (num_queues is set to 1 by default) to the destination hypervisor (num_queues is set to -smp N) lively. The different num-queues for virtio-scsi-pci devices between the=C2=A0source side and the destination side will result in migration failure due to loading vmstate incorrectly on the destination side. To provide a smooth upgrade solution, introduce the auto-num-queues property for the virtio-scsi-pci device. This allows upper APPs, e.g., libvirt, to recognize the hypervisor's capability of allocating the virtqueues automatically by probing the virtio-scsi-pci.auto-num-queues property. Basing on which, upper APPs can ensure to allocate the same num-queues on the destination side in case of migration failure. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- hw/scsi/vhost-scsi.c | 2 ++ hw/scsi/vhost-user-scsi.c | 2 ++ hw/scsi/virtio-scsi.c | 2 ++ hw/virtio/vhost-scsi-pci.c | 11 +++++++++-- hw/virtio/vhost-user-scsi-pci.c | 11 +++++++++-- hw/virtio/virtio-scsi-pci.c | 11 +++++++++-- include/hw/virtio/virtio-scsi.h | 5 +++++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 443f67daa4..78a8929c49 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -284,6 +284,8 @@ static Property vhost_scsi_properties[] =3D { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), DEFINE_PROP_UINT32("boot_tpgt", VirtIOSCSICommon, conf.boot_tpgt, 0), + DEFINE_PROP_BOOL("auto_num_queues", VirtIOSCSICommon, auto_num_queues, + true), DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, VIRTIO_SCSI_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSICommon, conf.virtqueue_= size, diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index ee99b19e7a..1b837f370a 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -161,6 +161,8 @@ static void vhost_user_scsi_unrealize(DeviceState *dev) static Property vhost_user_scsi_properties[] =3D { DEFINE_PROP_CHR("chardev", VirtIOSCSICommon, conf.chardev), DEFINE_PROP_UINT32("boot_tpgt", VirtIOSCSICommon, conf.boot_tpgt, 0), + DEFINE_PROP_BOOL("auto_num_queues", VirtIOSCSICommon, auto_num_queues, + true), DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, VIRTIO_SCSI_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSICommon, conf.virtqueue_= size, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 45b95ea070..2ec13032aa 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -1279,6 +1279,8 @@ static void virtio_scsi_device_unrealize(DeviceState = *dev) } =20 static Property virtio_scsi_properties[] =3D { + DEFINE_PROP_BOOL("auto_num_queues", VirtIOSCSI, parent_obj.auto_num_qu= eues, + true), DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, parent_obj.conf.num_queue= s, VIRTIO_SCSI_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSI, diff --git a/hw/virtio/vhost-scsi-pci.c b/hw/virtio/vhost-scsi-pci.c index 08980bc23b..927c155278 100644 --- a/hw/virtio/vhost-scsi-pci.c +++ b/hw/virtio/vhost-scsi-pci.c @@ -51,8 +51,15 @@ static void vhost_scsi_pci_realize(VirtIOPCIProxy *vpci_= dev, Error **errp) VirtIOSCSIConf *conf =3D &dev->vdev.parent_obj.parent_obj.conf; =20 if (conf->num_queues =3D=3D VIRTIO_SCSI_AUTO_NUM_QUEUES) { - conf->num_queues =3D - virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + /* + * Allocate virtqueues automatically only if auto_num_queues + * property set true. + */ + if (dev->vdev.parent_obj.parent_obj.auto_num_queues) + conf->num_queues =3D + virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + else + conf->num_queues =3D 1; } =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { diff --git a/hw/virtio/vhost-user-scsi-pci.c b/hw/virtio/vhost-user-scsi-pc= i.c index 75882e3cf9..9c521a7f93 100644 --- a/hw/virtio/vhost-user-scsi-pci.c +++ b/hw/virtio/vhost-user-scsi-pci.c @@ -57,8 +57,15 @@ static void vhost_user_scsi_pci_realize(VirtIOPCIProxy *= vpci_dev, Error **errp) VirtIOSCSIConf *conf =3D &dev->vdev.parent_obj.parent_obj.conf; =20 if (conf->num_queues =3D=3D VIRTIO_SCSI_AUTO_NUM_QUEUES) { - conf->num_queues =3D - virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + /* + * Allocate virtqueues automatically only if auto_num_queues + * property set true. + */ + if (dev->vdev.parent_obj.parent_obj.auto_num_queues) + conf->num_queues =3D + virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + else + conf->num_queues =3D 1; } =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { diff --git a/hw/virtio/virtio-scsi-pci.c b/hw/virtio/virtio-scsi-pci.c index e8e3442f38..7551857f90 100644 --- a/hw/virtio/virtio-scsi-pci.c +++ b/hw/virtio/virtio-scsi-pci.c @@ -52,8 +52,15 @@ static void virtio_scsi_pci_realize(VirtIOPCIProxy *vpci= _dev, Error **errp) char *bus_name; =20 if (conf->num_queues =3D=3D VIRTIO_SCSI_AUTO_NUM_QUEUES) { - conf->num_queues =3D - virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + /* + * Allocate virtqueues automatically only if auto_num_queues + * property set true. + */ + if (dev->vdev.parent_obj.auto_num_queues) + conf->num_queues =3D + virtio_pci_optimal_num_queues(VIRTIO_SCSI_VQ_NUM_FIXED); + else + conf->num_queues =3D 1; } =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scs= i.h index 779568ab5d..2660bbad22 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -72,6 +72,11 @@ struct VirtIOSCSICommon { VirtQueue *ctrl_vq; VirtQueue *event_vq; VirtQueue **cmd_vqs; + /* + * Set to true if virtqueues allow to be allocated to + * match the number of virtual CPUs automatically. + */ + bool auto_num_queues; }; =20 struct VirtIOSCSIReq; --=20 2.38.5 From nobody Sun May 19 13:07:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691651299883982.6292176261154; Thu, 10 Aug 2023 00:08:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTzlO-0005PC-De; Thu, 10 Aug 2023 03:07:18 -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 1qTzlK-0005O9-Uy for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:14 -0400 Received: from mail-b.sr.ht ([173.195.146.151]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTzlH-0004oI-WA for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:14 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 406E411EF58; Thu, 10 Aug 2023 07:07:10 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=none From: ~hyman Date: Sat, 05 Aug 2023 10:38:11 +0800 Subject: [PATCH QEMU v2 2/3] virtio-blk-pci: introduce auto-num-queues property MIME-Version: 1.0 Message-ID: <169165122958.4096.6557269987206106594-2@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <169165122958.4096.6557269987206106594-0@git.sr.ht> To: qemu-devel Cc: Raphael Norwitz , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng , yong.huang@smartx.com Content-Type: text/plain; charset="utf-8" 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=173.195.146.151; envelope-from=outgoing@sr.ht; helo=mail-b.sr.ht X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1691651300232100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Commit "9445e1e15 virtio-blk-pci: default num_queues to -smp N" implment sizing the number of virtio-blk-pci request virtqueues to match the number of vCPUs automatically. Which improves IO preformance remarkably. To enable this feature for the existing VMs, the cloud platform may migrate VMs from the source hypervisor (num_queues is set to 1 by default) to the destination hypervisor (num_queues is set to -smp N) lively. The different num-queues for virtio-blk-pci devices between the=C2=A0source side and the destination side will result in migration failure due to loading vmstate incorrectly on the destination side. To provide a smooth upgrade solution, introduce the auto-num-queues property for the virtio-blk-pci device. This allows upper APPs, e.g., libvirt, to recognize the hypervisor's capability of allocating the virtqueues automatically by probing the virtio-blk-pci.auto-num-queues property. Basing on which, upper APPs can ensure to allocate the same num-queues on the destination side in case of migration failure. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- hw/block/virtio-blk.c | 1 + hw/virtio/virtio-blk-pci.c | 9 ++++++++- include/hw/virtio/virtio-blk.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 39e7f23fab..9e498ca64a 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1716,6 +1716,7 @@ static Property virtio_blk_properties[] =3D { #endif DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, = 0, true), + DEFINE_PROP_BOOL("auto-num-queues", VirtIOBlock, auto_num_queues, true= ), DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, VIRTIO_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 256), diff --git a/hw/virtio/virtio-blk-pci.c b/hw/virtio/virtio-blk-pci.c index 9743bee965..4b6b4c4933 100644 --- a/hw/virtio/virtio-blk-pci.c +++ b/hw/virtio/virtio-blk-pci.c @@ -54,7 +54,14 @@ static void virtio_blk_pci_realize(VirtIOPCIProxy *vpci_= dev, Error **errp) VirtIOBlkConf *conf =3D &dev->vdev.conf; =20 if (conf->num_queues =3D=3D VIRTIO_BLK_AUTO_NUM_QUEUES) { - conf->num_queues =3D virtio_pci_optimal_num_queues(0); + /* + * Allocate virtqueues automatically only if auto_num_queues + * property set true. + */ + if (dev->vdev.auto_num_queues) + conf->num_queues =3D virtio_pci_optimal_num_queues(0); + else + conf->num_queues =3D 1; } =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index dafec432ce..dab6d7c70c 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -65,6 +65,11 @@ struct VirtIOBlock { uint64_t host_features; size_t config_size; BlockRAMRegistrar blk_ram_registrar; + /* + * Set to true if virtqueues allow to be allocated to + * match the number of virtual CPUs automatically. + */ + bool auto_num_queues; }; =20 typedef struct VirtIOBlockReq { --=20 2.38.5 From nobody Sun May 19 13:07:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1691651279873492.4624771968604; Thu, 10 Aug 2023 00:07:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTzlM-0005Ox-8t; Thu, 10 Aug 2023 03:07:16 -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 1qTzlK-0005OA-V7 for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:14 -0400 Received: from mail-b.sr.ht ([173.195.146.151]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTzlI-0004oJ-02 for qemu-devel@nongnu.org; Thu, 10 Aug 2023 03:07:14 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 6917311EF74; Thu, 10 Aug 2023 07:07:10 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=none From: ~hyman Date: Sat, 05 Aug 2023 08:39:56 +0800 Subject: [PATCH QEMU v2 3/3] vhost-user-blk-pci: introduce auto-num-queues property MIME-Version: 1.0 Message-ID: <169165122958.4096.6557269987206106594-3@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <169165122958.4096.6557269987206106594-0@git.sr.ht> To: qemu-devel Cc: Raphael Norwitz , "Michael S. Tsirkin" , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng , yong.huang@smartx.com Content-Type: text/plain; charset="utf-8" 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=173.195.146.151; envelope-from=outgoing@sr.ht; helo=mail-b.sr.ht X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1691651282078100010 From: Hyman Huang(=E9=BB=84=E5=8B=87) Commit "a4eef0711b vhost-user-blk-pci: default num_queues to -smp N" implment sizing the number of vhost-user-blk-pci request virtqueues to match the number of vCPUs automatically. Which improves IO preformance remarkably. To enable this feature for the existing VMs, the cloud platform may migrate VMs from the source hypervisor (num_queues is set to 1 by default) to the destination hypervisor (num_queues is set to -smp N) lively. The different num-queues for vhost-user-blk-pci devices between the=C2=A0source side and the destination side will result in migration failure due to loading vmstate incorrectly on the destination side. To provide a smooth upgrade solution, introduce the auto-num-queues property for the vhost-user-blk-pci device. This allows upper APPs, e.g., libvirt, to recognize the hypervisor's capability of allocating the virtqueues automatically by probing the vhost-user-blk-pci.auto-num-queues property. Basing on which, upper APPs can ensure to allocate the same num-queues on the destination side in case of migration failure. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- hw/block/vhost-user-blk.c | 1 + hw/virtio/vhost-user-blk-pci.c | 9 ++++++++- include/hw/virtio/vhost-user-blk.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index eecf3f7a81..34e23b1727 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -566,6 +566,7 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { =20 static Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), + DEFINE_PROP_BOOL("auto-num-queues", VHostUserBlk, auto_num_queues, tru= e), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, VHOST_USER_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128), diff --git a/hw/virtio/vhost-user-blk-pci.c b/hw/virtio/vhost-user-blk-pci.c index eef8641a98..f7776e928a 100644 --- a/hw/virtio/vhost-user-blk-pci.c +++ b/hw/virtio/vhost-user-blk-pci.c @@ -56,7 +56,14 @@ static void vhost_user_blk_pci_realize(VirtIOPCIProxy *v= pci_dev, Error **errp) DeviceState *vdev =3D DEVICE(&dev->vdev); =20 if (dev->vdev.num_queues =3D=3D VHOST_USER_BLK_AUTO_NUM_QUEUES) { - dev->vdev.num_queues =3D virtio_pci_optimal_num_queues(0); + /* + * Allocate virtqueues automatically only if auto_num_queues + * property set true. + */ + if (dev->vdev.auto_num_queues) + dev->vdev.num_queues =3D virtio_pci_optimal_num_queues(0); + else + dev->vdev.num_queues =3D 1; } =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index ea085ee1ed..e6f0515bc6 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -50,6 +50,11 @@ struct VHostUserBlk { bool connected; /* vhost_user_blk_start/vhost_user_blk_stop */ bool started_vu; + /* + * Set to true if virtqueues allow to be allocated to + * match the number of virtual CPUs automatically. + */ + bool auto_num_queues; }; =20 #endif --=20 2.38.5