@@ -1716,6 +1716,7 @@ static Property virtio_blk_properties[] = {
#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),
@@ -54,7 +54,14 @@ static void virtio_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
VirtIOBlkConf *conf = &dev->vdev.conf;
if (conf->num_queues == VIRTIO_BLK_AUTO_NUM_QUEUES) {
- conf->num_queues = 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 = virtio_pci_optimal_num_queues(0);
+ else
+ conf->num_queues = 1;
}
if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
@@ -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;
};
typedef struct VirtIOBlockReq {