diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5dcf2fedb01cb9aaf5d6e355d3f0e56b3c3029ad..c0e3c222136f5e432f800faf8c0ca6076d625bc2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2397,7 +2397,7 @@
<target dev='vdc' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
- <driver name='qemu' type='qcow2'/>
+ <driver name='qemu' type='qcow2' queues='4'/>
<source file='/var/lib/libvirt/images/domain.qcow'/>
<backingStore type='file'>
<format type='qcow2'/>
@@ -3057,6 +3057,10 @@
bus
and "pci" or "ccw" address
types.
Since 1.2.8 (QEMU 2.1)
+
+ The optional queues
attribute specifies the number of
+ virt queues for virtio-blk. (Since 3.9.0)
+
For virtio disks,
Virtio-specific options can also be
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index bac371ea3246ace6afb5db6ca87e9b5cf450ec0f..66b3d70c66ba61d714599c9872f7892778fb1f04 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1811,6 +1811,11 @@
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ebaa3ce0b4d499f4b6be65bade0731630525948b..51aed84917418f0034982d58ad18077eb71d513c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5113,6 +5113,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
return -1;
}
+ if (disk->queues && disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("queues attribute in disk driver element is only "
+ "supported by virtio-blk"));
+ return -1;
+ }
+
return 0;
}
@@ -8776,6 +8783,15 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
}
VIR_FREE(tmp);
+ if ((tmp = virXMLPropString(cur, "queues")) &&
+ virStrToLong_uip(tmp, NULL, 10, &def->queues) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("'queues' attribute must be positive number: %s"),
+ tmp);
+ goto cleanup;
+ }
+ VIR_FREE(tmp);
+
ret = 0;
cleanup:
@@ -22030,6 +22046,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
if (def->detect_zeroes)
virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
+ if (def->queues)
+ virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 05a035a16086f478c0d69c6b8166cf76f88b0707..28abe2b0b20c7942d88a2dcf1b0bdc94e171bb1c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
unsigned int iothread; /* unused = 0, > 0 specific thread # */
int detect_zeroes; /* enum virDomainDiskDetectZeroes */
char *domain_name; /* backend domain name */
+ unsigned int queues;
virDomainVirtioOptionsPtr virtio;
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4f141e0ac312f012898606fd0d47b0ed9e1d0ecd..72318672edd66f251f984d483728d3f5c7ef58fe 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2083,6 +2083,17 @@ qemuBuildDriveDevStr(const virDomainDef *def,
? "on" : "off");
}
+ if (disk->queues) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("num-queues property isn't supported by this "
+ "QEMU binary"));
+ goto error;
+ }
+
+ virBufferAsprintf(&opt, ",num-queues=%u", disk->queues);
+ }
+
if (qemuBuildVirtioOptionsStr(&opt, disk->virtio, qemuCaps) < 0)
goto error;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 1a47396ab27d8d8ee430b3f5a387ce8851446cb1..9632a9af8402b3d7531341d089b9cb5259332dc2 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -883,6 +883,9 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
+int qemuDomainDefValidateDisk(const virDomainDiskDef *disk,
+ virQEMUCapsPtr qemuCaps);
+
int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.args
new file mode 100644
index 0000000000000000000000000000000000000000..3c82abf142f459e17c46f06e4c4d912d980cafe7
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/tmp/data.img,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-pci,num-queues=4,bus=pci.0,addr=0x3,\
+drive=drive-virtio-disk0,id=virtio-disk0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.xml
new file mode 100644
index 0000000000000000000000000000000000000000..37885c6f9c538f8124352b5333424a4f94a641de
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-drive-queues.xml
@@ -0,0 +1,34 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-i686
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7271ea07e841d1b013584b63af9f7807be76e52e..a505864b87e0b0ae990e9222b2eae158bec71bfd 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -892,6 +892,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-order",
QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
+ DO_TEST("disk-virtio-drive-queues",
+ QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
DO_TEST("disk-drive-boot-disk",
QEMU_CAPS_DRIVE_BOOT);
DO_TEST("disk-drive-boot-cdrom",
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-virtio-drive-queues.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-virtio-drive-queues.xml
new file mode 100644
index 0000000000000000000000000000000000000000..37885c6f9c538f8124352b5333424a4f94a641de
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-virtio-drive-queues.xml
@@ -0,0 +1,34 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-i686
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2dba3607c0a8a8a168a9af9b5c4f08a102d3ceee..73489eed930802f47d90c0bedbb87b13673a23d2 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -449,6 +449,7 @@ mymain(void)
DO_TEST("disk-usb-device", NONE);
DO_TEST("disk-virtio", NONE);
DO_TEST("floppy-drive-fat", NONE);
+ DO_TEST("disk-virtio-drive-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
DO_TEST("disk-drive-boot-disk", NONE);
DO_TEST("disk-drive-boot-cdrom", NONE);
DO_TEST("disk-drive-error-policy-stop", NONE);