On 04/22/2016 01:24 AM, John Ferlan wrote:
Add the ability to add an 'iothread' to the controller which will be how
virtio-scsi-pci and virtio-scsi-ccw iothreads have been implemented in qemu.
Describe the new functionality and add tests to parse/validate that the
new attribute can be added.
Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
docs/formatdomain.html.in | 33 +++++++++++---
docs/schemas/domaincommon.rng | 3 ++
src/conf/domain_conf.c | 25 ++++++++++-
src/conf/domain_conf.h | 1 +
.../qemuxml2argv-iothreads-virtio-scsi-ccw.xml | 39 +++++++++++++++++
.../qemuxml2argv-iothreads-virtio-scsi-pci.xml | 47 ++++++++++++++++++++
.../qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml | 39 +++++++++++++++++
.../qemuxml2xmlout-iothreads-virtio-scsi-pci.xml | 51 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 7 +++
9 files changed, 239 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-pci.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index bcb8159..e04ee9e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -565,11 +565,13 @@
<dt><code>iothreads</code></dt>
<dd>
The content of this optional element defines the number
- of IOThreads to be assigned to the domain for use by
- virtio-blk-pci and virtio-blk-ccw target storage devices. There
- should be only 1 or 2 IOThreads per host CPU. There may be more
- than one supported device assigned to each IOThread.
- <span class="since">Since 1.2.8</span>
+ of IOThreads to be assigned to the domain for use by supported
+ storage disks or controllers. There should be only 1 or 2 IOThreads
+ per host CPU. There may be more than one supported device assigned
+ to each IOThread. Supported for virtio-blk-pci and virtio-blk-ccw
+ disk devices <span class="since">since 1.2.8 (QEMU 2.1)</span>.
+ Supported for virtio-scsi-pci and virtio-scsi-ccw controller
+ devices <span class="since">since 1.3.4 (QEMU 2.4)</span>.
</dd>
<dt><code>iothreadids</code></dt>
<dd>
@@ -3001,6 +3003,10 @@
<controller type='virtio-serial' index='1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</controller>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver iothread='4'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+ </controller>
...
</devices>
...</pre>
@@ -3081,6 +3087,23 @@
I/O asynchronous handling</a> or not. Accepted values are
"on" and "off". <span class="since">Since 1.2.18</span>
</dd>
+ <dt><code>iothread</code></dt>
+ <dd>
+ Supported for controller type <code>scsi</code> using model
+ <code>virtio-scsi</code> for <code>address</code> types
+ <code>pci</code> and <code>ccw</code>
+ <span class="since">since 1.3.4 (QEMU 2.4)</span>.
+
+ The optional <code>iothread</code> attribute assigns the controller
+ to an IOThread as defined by the range for the domain
+ <a href="#elementsIOThreadsAllocation"><code>iothreads</code></a>
+ value. Each SCSI <code>disk</code> assigned to use the specified
+ <code>controller</code> will utilize the same IOThread. If a specific
+ IOThread is desired for a specific SCSI <code>disk</code>, then
+ multiple controllers must be defined each having a specific
+ <code>iothread</code> value. The <code>iothread</code> value
+ must be within the range 1 to the domain iothreads value.
+ </dd>
</dl>
<p>
USB companion controllers have an optional
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3605afe..5196289 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1891,6 +1891,9 @@
<optional>
<ref name="ioeventfd"/>
</optional>
+ <optional>
+ <ref name="driverIOThread"/>
+ </optional>
</element>
</optional>
</interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd7579a..32e3dcd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7847,6 +7847,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *busNr = NULL;
int numaNode = -1;
char *ioeventfd = NULL;
+ char *iothread = NULL;
xmlNodePtr saved = ctxt->node;
int rc;
@@ -7891,6 +7892,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
cmd_per_lun = virXMLPropString(cur, "cmd_per_lun");
max_sectors = virXMLPropString(cur, "max_sectors");
ioeventfd = virXMLPropString(cur, "ioeventfd");
+ iothread = virXMLPropString(cur, "iothread");
} else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
if (processedModel) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -7952,6 +7954,21 @@ virDomainControllerDefParseXML(xmlNodePtr node,
goto error;
}
+ if (iothread) {
+ if (def->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("'iothread' attribute only supported for "
+ "controller model '%s'"),
+ virDomainControllerModelTypeToString(def, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI));
virDomainControllerModelSCSITypeToString(VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)
Otherwise you can end up with a rather useless error messages that looks
like this: error: XML error: 'iothread' attribute only supported for
controller model '(null)'
e.g. if the controller is of type 'virtio-serial'.
+ goto error;
+ }
+ if (virStrToLong_uip(iothread, NULL, 10, &def->iothread) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid 'iothread' value '%s'"), iothread);
+ goto error;
+ }
+ }
+
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
def->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
VIR_DEBUG("Ignoring device address for none model usb controller");
@@ -8135,6 +8152,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
VIR_FREE(port);
VIR_FREE(busNr);
VIR_FREE(ioeventfd);
+ VIR_FREE(iothread);
return def;
@@ -19466,6 +19484,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
if (pciModel || pciTarget ||
def->queues || def->cmd_per_lun || def->max_sectors || def->ioeventfd ||
+ def->iothread ||
virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
@@ -19508,7 +19527,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
}
if (def->queues || def->cmd_per_lun ||
- def->max_sectors || def->ioeventfd) {
+ def->max_sectors || def->ioeventfd || def->iothread) {
virBufferAddLit(buf, "<driver");
if (def->queues)
virBufferAsprintf(buf, " queues='%u'", def->queues);
@@ -19523,6 +19542,10 @@ virDomainControllerDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " ioeventfd='%s'",
virTristateSwitchTypeToString(def->ioeventfd));
}
+
+ if (def->iothread)
+ virBufferAsprintf(buf, " iothread='%u'", def->iothread);
+
virBufferAddLit(buf, "/>\n");
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fd540ed..bcc0d91 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -854,6 +854,7 @@ struct _virDomainControllerDef {
unsigned int cmd_per_lun;
unsigned int max_sectors;
int ioeventfd; /* enum virTristateSwitch */
+ unsigned int iothread; /* unused = 0, > 0 specific thread # */
union {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.xml b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.xml
new file mode 100644
index 0000000..2499782
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.xml
@@ -0,0 +1,39 @@
+<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>
+ <iothreads>2</iothreads>
+ <os>
+ <type arch='s390x' machine='s390-ccw'>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</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw' iothread='1'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sdb' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver iothread='2'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </controller>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x000a'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.xml
new file mode 100644
index 0000000..b427bcc
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.xml
@@ -0,0 +1,47 @@
+<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'>2</vcpu>
+ <iothreads>2</iothreads>
+ <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</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw' iothread='1'/>
+ <source file='/var/lib/libvirt/images/iothrtest1.img'/>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/images/iothrtest2.img'/>
+ <target dev='sdc' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='3'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver iothread='2'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml
new file mode 100644
index 0000000..2499782
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml
@@ -0,0 +1,39 @@
+<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>
+ <iothreads>2</iothreads>
+ <os>
+ <type arch='s390x' machine='s390-ccw'>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</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw' iothread='1'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sdb' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver iothread='2'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </controller>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x000a'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-pci.xml
new file mode 100644
index 0000000..d8306d4
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-pci.xml
@@ -0,0 +1,51 @@
+<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'>2</vcpu>
+ <iothreads>2</iothreads>
+ <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</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw' iothread='1'/>
+ <source file='/var/lib/libvirt/images/iothrtest1.img'/>
+ <target dev='vdb' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/images/iothrtest2.img'/>
+ <target dev='sdc' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='3'/>
+ </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'/>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver iothread='2'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index f766f4d..ad8143f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -511,6 +511,13 @@ mymain(void)
DO_TEST("iothreads-disk");
DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_ACTIVE,
QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
+ DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_ACTIVE,
+ QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_VIRTIO_SCSI);
+ DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_ACTIVE,
+ QEMU_CAPS_VIRTIO_SCSI,
+ QEMU_CAPS_VIRTIO_CCW,
+ QEMU_CAPS_VIRTIO_S390);
DO_TEST("lease");
DO_TEST("event_idx");
DO_TEST("vhost_queues");
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list