@@ -566,6 +566,7 @@ static const VMStateDescription vmstate_vhost_user_blk = {
static Property vhost_user_blk_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev),
+ DEFINE_PROP_BOOL("auto-num-queues", VHostUserBlk, auto_num_queues, true),
DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues,
VHOST_USER_BLK_AUTO_NUM_QUEUES),
DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128),
@@ -56,7 +56,14 @@ static void vhost_user_blk_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
DeviceState *vdev = DEVICE(&dev->vdev);
if (dev->vdev.num_queues == VHOST_USER_BLK_AUTO_NUM_QUEUES) {
- dev->vdev.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)
+ dev->vdev.num_queues = virtio_pci_optimal_num_queues(0);
+ else
+ dev->vdev.num_queues = 1;
}
if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
@@ -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;
};
#endif