[PATCH 5/5] qemu: add virtio-blk queue-size option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The option "queue-size" in virtio-blk was added in qemu-2.12.0, and default value increased from qemu-5.0.0.

However, increasing this value may lead to drop of random access performance.

This is configurable value, so we want to use it via libvirt.

Signed-off-by: Hiroki Narukawa <hnarukaw@xxxxxxxxxxxxx>
---
 src/qemu/qemu_command.c                       |  3 ++
 src/qemu/qemu_validate.c                      |  7 ++++
 .../disk-virtio-queue-size.args               | 35 +++++++++++++++++
 .../disk-virtio-queue-size.x86_64-latest.args | 35 +++++++++++++++++
 .../disk-virtio-queue-size.xml                | 38 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  1 +
 .../disk-virtio-queue-size.x86_64-latest.xml  | 38 +++++++++++++++++++
 .../disk-virtio-queue-size.xml                | 35 +++++++++++++++++
 tests/qemuxml2xmltest.c                       |  1 +
 9 files changed, 193 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/disk-virtio-queue-size.args
 create mode 100644 tests/qemuxml2argvdata/disk-virtio-queue-size.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-virtio-queue-size.xml
 create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-queue-size.x86_64-latest.xml
 create mode 100644 tests/qemuxml2xmloutdata/disk-virtio-queue-size.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b230314f7f..f0319d2234 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1738,6 +1738,9 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
         if (disk->queues) {
             virBufferAsprintf(&opt, ",num-queues=%u", disk->queues);
         }
+        if (disk->queue_size > 0) {
+            virBufferAsprintf(&opt, ",queue-size=%u", disk->queue_size);
+        }
 
         qemuBuildVirtioOptionsStr(&opt, disk->virtio);
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 1a470f1ff5..16ccf2e76d 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -2823,6 +2823,13 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
                              "QEMU binary"));
             return -1;
         }
+        if (disk->queue_size &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("queue-size property isn't supported by this "
+                             "QEMU binary"));
+            return -1;
+        }
         break;
 
     case VIR_DOMAIN_DISK_BUS_USB:
diff --git a/tests/qemuxml2argvdata/disk-virtio-queue-size.args b/tests/qemuxml2argvdata/disk-virtio-queue-size.args
new file mode 100644
index 0000000000..2985e1726c
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-queue-size.args
@@ -0,0 +1,35 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-cpu qemu64 \
+-m 214 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-blockdev '{"driver":"file","filename":"/tmp/data.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \
+-device virtio-blk-pci,queue-size=4,bus=pci.0,addr=0x3,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \
+-audiodev id=audio1,driver=none \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-virtio-queue-size.x86_64-latest.args b/tests/qemuxml2argvdata/disk-virtio-queue-size.x86_64-latest.args
new file mode 100644
index 0000000000..2985e1726c
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-queue-size.x86_64-latest.args
@@ -0,0 +1,35 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-cpu qemu64 \
+-m 214 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-blockdev '{"driver":"file","filename":"/tmp/data.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \
+-device virtio-blk-pci,queue-size=4,bus=pci.0,addr=0x3,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \
+-audiodev id=audio1,driver=none \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-virtio-queue-size.xml b/tests/qemuxml2argvdata/disk-virtio-queue-size.xml
new file mode 100644
index 0000000000..1cd3f830e5
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-virtio-queue-size.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i386</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw' queue_size='4'/>
+      <source file='/tmp/data.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </disk>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 59dfef52fd..8f6058f947 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1340,6 +1340,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR("non-x86_64-timer-error", QEMU_CAPS_CCW);
     DO_TEST("disk-order", QEMU_CAPS_VIRTIO_BLK_SCSI);
     DO_TEST_CAPS_LATEST("disk-virtio-queues");
+    DO_TEST_CAPS_LATEST("disk-virtio-queue-size");
     DO_TEST_NOCAPS("disk-boot-disk");
     DO_TEST_NOCAPS("disk-boot-cdrom");
     DO_TEST_NOCAPS("floppy-drive-fat");
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-queue-size.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-virtio-queue-size.x86_64-latest.xml
new file mode 100644
index 0000000000..1cd3f830e5
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-virtio-queue-size.x86_64-latest.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu mode='custom' match='exact' check='none'>
+    <model fallback='forbid'>qemu64</model>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i386</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw' queue_size='4'/>
+      <source file='/tmp/data.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </disk>
+    <controller type='usb' index='0' model='piix3-uhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-queue-size.xml b/tests/qemuxml2xmloutdata/disk-virtio-queue-size.xml
new file mode 100644
index 0000000000..19d886fd65
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-virtio-queue-size.xml
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i386</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw' queue_size='4'/>
+      <source file='/tmp/data.img'/>
+      <target dev='vda' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </disk>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <audio id='1' type='none'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b88f7c404d..d7dd37f061 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -302,6 +302,7 @@ mymain(void)
     DO_TEST_NOCAPS("disk-virtio");
     DO_TEST_NOCAPS("floppy-drive-fat");
     DO_TEST_CAPS_LATEST("disk-virtio-queues");
+    DO_TEST_CAPS_LATEST("disk-virtio-queue-size");
     DO_TEST_NOCAPS("disk-boot-disk");
     DO_TEST_NOCAPS("disk-boot-cdrom");
     DO_TEST_NOCAPS("disk-error-policy");
-- 
2.17.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux