提交 abca72fa 编写于 作者: L Lin Ma 提交者: Ján Tomko

qemu: Support multiqueue virtio-blk

qemu 2.7.0 introduces multiqueue virtio-blk(commit 2f27059).
This patch introduces a new attribute "queues". An example of
the XML:

<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' queues='4'/>

The corresponding QEMU command line:

-device virtio-blk-pci,scsi=off,num-queues=4,id=virtio-disk0
Signed-off-by: NLin Ma <lma@suse.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 c7bdeed5
...@@ -2397,7 +2397,7 @@ ...@@ -2397,7 +2397,7 @@
&lt;target dev='vdc' bus='virtio'/&gt; &lt;target dev='vdc' bus='virtio'/&gt;
&lt;/disk&gt; &lt;/disk&gt;
&lt;disk type='file' device='disk'&gt; &lt;disk type='file' device='disk'&gt;
&lt;driver name='qemu' type='qcow2'/&gt; &lt;driver name='qemu' type='qcow2' queues='4'/&gt;
&lt;source file='/var/lib/libvirt/images/domain.qcow'/&gt; &lt;source file='/var/lib/libvirt/images/domain.qcow'/&gt;
&lt;backingStore type='file'&gt; &lt;backingStore type='file'&gt;
&lt;format type='qcow2'/&gt; &lt;format type='qcow2'/&gt;
...@@ -3057,6 +3057,10 @@ ...@@ -3057,6 +3057,10 @@
<code>bus</code> and "pci" or "ccw" <code>address</code> types. <code>bus</code> and "pci" or "ccw" <code>address</code> types.
<span class='since'>Since 1.2.8 (QEMU 2.1)</span> <span class='since'>Since 1.2.8 (QEMU 2.1)</span>
</li> </li>
<li>
The optional <code>queues</code> attribute specifies the number of
virt queues for virtio-blk. (<span class="since">Since 3.9.0</span>)
</li>
<li> <li>
For virtio disks, For virtio disks,
<a href="#elementsVirtio">Virtio-specific options</a> can also be <a href="#elementsVirtio">Virtio-specific options</a> can also be
......
...@@ -1811,6 +1811,11 @@ ...@@ -1811,6 +1811,11 @@
<optional> <optional>
<ref name="detect_zeroes"/> <ref name="detect_zeroes"/>
</optional> </optional>
<optional>
<attribute name='queues'>
<ref name="positiveInteger"/>
</attribute>
</optional>
<ref name="virtioOptions"/> <ref name="virtioOptions"/>
<empty/> <empty/>
</element> </element>
......
...@@ -5113,6 +5113,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk) ...@@ -5113,6 +5113,13 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
return -1; 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; return 0;
} }
...@@ -8776,6 +8783,15 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, ...@@ -8776,6 +8783,15 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
} }
VIR_FREE(tmp); 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; ret = 0;
cleanup: cleanup:
...@@ -22030,6 +22046,8 @@ virDomainDiskDefFormat(virBufferPtr buf, ...@@ -22030,6 +22046,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread); virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
if (def->detect_zeroes) if (def->detect_zeroes)
virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes); virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes);
if (def->queues)
virBufferAsprintf(&driverBuf, " queues='%u'", def->queues);
virDomainVirtioOptionsFormat(&driverBuf, def->virtio); virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
......
...@@ -668,6 +668,7 @@ struct _virDomainDiskDef { ...@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
unsigned int iothread; /* unused = 0, > 0 specific thread # */ unsigned int iothread; /* unused = 0, > 0 specific thread # */
int detect_zeroes; /* enum virDomainDiskDetectZeroes */ int detect_zeroes; /* enum virDomainDiskDetectZeroes */
char *domain_name; /* backend domain name */ char *domain_name; /* backend domain name */
unsigned int queues;
virDomainVirtioOptionsPtr virtio; virDomainVirtioOptionsPtr virtio;
}; };
......
...@@ -2083,6 +2083,17 @@ qemuBuildDriveDevStr(const virDomainDef *def, ...@@ -2083,6 +2083,17 @@ qemuBuildDriveDevStr(const virDomainDef *def,
? "on" : "off"); ? "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) if (qemuBuildVirtioOptionsStr(&opt, disk->virtio, qemuCaps) < 0)
goto error; goto error;
......
...@@ -883,6 +883,9 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def) ...@@ -883,6 +883,9 @@ bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def)
void qemuDomainVcpuPersistOrder(virDomainDefPtr def) void qemuDomainVcpuPersistOrder(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int qemuDomainDefValidateDisk(const virDomainDiskDef *disk,
virQEMUCapsPtr qemuCaps);
int qemuDomainCheckMonitor(virQEMUDriverPtr driver, int qemuDomainCheckMonitor(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob); qemuDomainAsyncJob asyncJob);
......
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
<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-i686</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' queues='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'/>
<memballoon model='none'/>
</devices>
</domain>
...@@ -892,6 +892,8 @@ mymain(void) ...@@ -892,6 +892,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("disk-order", DO_TEST("disk-order",
QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI); 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", DO_TEST("disk-drive-boot-disk",
QEMU_CAPS_DRIVE_BOOT); QEMU_CAPS_DRIVE_BOOT);
DO_TEST("disk-drive-boot-cdrom", DO_TEST("disk-drive-boot-cdrom",
......
<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-i686</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' queues='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'/>
<memballoon model='none'/>
</devices>
</domain>
...@@ -449,6 +449,7 @@ mymain(void) ...@@ -449,6 +449,7 @@ mymain(void)
DO_TEST("disk-usb-device", NONE); DO_TEST("disk-usb-device", NONE);
DO_TEST("disk-virtio", NONE); DO_TEST("disk-virtio", NONE);
DO_TEST("floppy-drive-fat", 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-disk", NONE);
DO_TEST("disk-drive-boot-cdrom", NONE); DO_TEST("disk-drive-boot-cdrom", NONE);
DO_TEST("disk-drive-error-policy-stop", NONE); DO_TEST("disk-drive-error-policy-stop", NONE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册