[libvirt] [PATCH v2 0/3] Add support for virtio-scsi-{pci, ccw} iothread support

v1 here: http://www.redhat.com/archives/libvir-list/2016-May/msg00077.html (patches 1-4 were pushed already, the following are patches 5-7) Changes: Patch 1: - Clean up docs, use 1.3.5 as the version instead of 1.3.4. - Use post parse callback virDomainDeviceDefPostParseInternal to handle the controller check if iothread's are set on a controller (rather than during Controller Def parsing Patch 2: - Clean up commit message - Use the _() for message - Use 'target' not 'dst' in message (more specific) Patch 3: - No changes John Ferlan (3): conf: Add support for virtio-scsi iothreads qemu: Use switch for qemuCheckIOThreads qemu: Add 'iothread' to command line for supported controller docs/formatdomain.html.in | 21 ++++ docs/schemas/domaincommon.rng | 3 + src/conf/domain_conf.c | 32 +++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 115 ++++++++++++++++++--- .../qemuxml2argv-iothreads-virtio-scsi-ccw.args | 28 +++++ .../qemuxml2argv-iothreads-virtio-scsi-ccw.xml | 39 +++++++ .../qemuxml2argv-iothreads-virtio-scsi-pci.args | 32 ++++++ .../qemuxml2argv-iothreads-virtio-scsi-pci.xml | 47 +++++++++ tests/qemuxml2argvtest.c | 6 ++ .../qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml | 40 +++++++ .../qemuxml2xmlout-iothreads-virtio-scsi-pci.xml | 51 +++++++++ tests/qemuxml2xmltest.c | 7 ++ 13 files changed, 409 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.args 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 -- 2.5.5

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@redhat.com> --- docs/formatdomain.html.in | 21 +++++++++ docs/schemas/domaincommon.rng | 3 ++ src/conf/domain_conf.c | 32 +++++++++++++- 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 | 40 +++++++++++++++++ .../qemuxml2xmlout-iothreads-virtio-scsi-pci.xml | 51 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 7 +++ 9 files changed, 240 insertions(+), 1 deletion(-) 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 d01a887..97794b7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3005,6 +3005,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> @@ -3092,6 +3096,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.5 (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 966e931..273715c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1899,6 +1899,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 81621b9..2c97bc1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4250,6 +4250,20 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, } } } + + if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) { + virDomainControllerDefPtr cdev = dev->data.controller; + + if (cdev->iothread && + cdev->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) { + virReportError(VIR_ERR_XML_ERROR, + _("'iothread' attribute only supported for " + "controller model '%s'"), + virDomainControllerModelSCSITypeToString(VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)); + return -1; + } + } + return 0; } @@ -7857,6 +7871,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, char *ioeventfd = NULL; char *portsStr = NULL; int ports = -1; + char *iothread = NULL; xmlNodePtr saved = ctxt->node; int rc; @@ -7901,6 +7916,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", @@ -7962,6 +7978,14 @@ virDomainControllerDefParseXML(xmlNodePtr node, goto error; } + if (iothread) { + 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"); @@ -8147,6 +8171,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, VIR_FREE(busNr); VIR_FREE(ioeventfd); VIR_FREE(portsStr); + VIR_FREE(iothread); return def; @@ -19490,6 +19515,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); @@ -19532,7 +19558,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); @@ -19547,6 +19573,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 583b3b4..b7b099c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -861,6 +861,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..5e91f1c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-virtio-scsi-ccw.xml @@ -0,0 +1,40 @@ +<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> + <panic model='s390'/> + </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 a68bd25..5a43fa9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -512,6 +512,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"); -- 2.5.5

Rather than an if statement, use a switch. The switch will also catch the illegal usage of 'iothread' with some other kind of unsupported bus configuration. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_command.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fbe61c2..97868ae 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1468,12 +1468,29 @@ qemuCheckIOThreads(const virDomainDef *def, virDomainDiskDefPtr disk) { /* Right "type" of disk" */ - if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO || - (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IOThreads only available for virtio pci and " - "virtio ccw disk")); + switch ((virDomainDiskBus)disk->bus) { + case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads only available for virtio pci and " + "virtio ccw disk")); + return false; + } + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("IOThreads not available for bus %s target %s"), + virDomainDiskBusTypeToString(disk->bus), disk->dst); return false; } -- 2.5.5

https://bugzilla.redhat.com/show_bug.cgi?id=1286709 Now that we have all the pieces in place, we can add the 'iothread=#' to the command line for the (two) controllers that support it (virtio-scsi-pci and virtio-scsi-ccw). Add the tests as well... Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_command.c | 86 ++++++++++++++++++++-- .../qemuxml2argv-iothreads-virtio-scsi-ccw.args | 28 +++++++ .../qemuxml2argv-iothreads-virtio-scsi-pci.args | 32 ++++++++ tests/qemuxml2argvtest.c | 6 ++ 4 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 97868ae..08c6c61 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2191,6 +2191,65 @@ qemuBuildUSBControllerDevStr(const virDomainDef *domainDef, return 0; } + +/* qemuCheckSCSIControllerIOThreads: + * @domainDef: Pointer to domain def + * @def: Pointer to controller def + * @qemuCaps: Capabilities + * + * If this controller definition has iothreads set, let's make sure the + * configuration is right before adding to the command line + * + * Returns true if either supported or there are no iothreads for controller; + * otherwise, returns false if configuration is not quite right. + */ +static bool +qemuCheckSCSIControllerIOThreads(const virDomainDef *domainDef, + virDomainControllerDefPtr def, + virQEMUCapsPtr qemuCaps) +{ + if (!def->iothread) + return true; + + /* By this time QEMU_CAPS_OBJECT_IOTHREAD was already checked. + * We just need to check if the QEMU_CAPS_VIRTIO_SCSI_IOTHREAD + * capability is set. + */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads for virtio-scsi not supported for " + "this QEMU")); + return false; + } + + if (def->model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("IOThreads only supported for virtio-scsi " + "controllers model is '%s'"), + virDomainControllerModelSCSITypeToString(def->model)); + return false; + } + + if (def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads only available for virtio pci and " + "virtio ccw controllers")); + return false; + } + + /* Can we find the controller iothread in the iothreadid list? */ + if (!virDomainIOThreadIDFind(domainDef, def->iothread)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("controller iothread '%u' not defined in iothreadid"), + def->iothread); + return false; + } + + return true; +} + + char * qemuBuildControllerDevStr(const virDomainDef *domainDef, virDomainControllerDefPtr def, @@ -2238,16 +2297,31 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch (model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) + if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { virBufferAddLit(&buf, "virtio-scsi-ccw"); - else if (def->info.type == - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) + if (def->iothread) { + if (!qemuCheckSCSIControllerIOThreads(domainDef, + def, qemuCaps)) + goto error; + virBufferAsprintf(&buf, ",iothread=iothread%u", + def->iothread); + } + } else if (def->info.type == + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { virBufferAddLit(&buf, "virtio-scsi-s390"); - else if (def->info.type == - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) + } else if (def->info.type == + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { virBufferAddLit(&buf, "virtio-scsi-device"); - else + } else { virBufferAddLit(&buf, "virtio-scsi-pci"); + if (def->iothread) { + if (!qemuCheckSCSIControllerIOThreads(domainDef, + def, qemuCaps)) + goto error; + virBufferAsprintf(&buf, ",iothread=iothread%u", + def->iothread); + } + } break; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: virBufferAddLit(&buf, "lsi"); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args new file mode 100644 index 0000000..edf49bf --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-ccw.args @@ -0,0 +1,28 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M s390-ccw \ +-m 214 \ +-smp 1 \ +-object iothread,id=iothread1 \ +-object iothread,id=iothread2 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device virtio-scsi-ccw,iothread=iothread2,id=scsi0,devno=fe.0.0001 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ +-device virtio-blk-ccw,iothread=iothread1,devno=fe.0.0000,\ +drive=drive-virtio-disk0,id=virtio-disk0 \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-scsi0-0-2-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=2,lun=0,drive=drive-scsi0-0-2-0,\ +id=scsi0-0-2-0 \ +-device virtio-balloon-ccw,id=balloon0,devno=fe.0.000a diff --git a/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.args new file mode 100644 index 0000000..bd83b27 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-iothreads-virtio-scsi-pci.args @@ -0,0 +1,32 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 2 \ +-object iothread,id=iothread1 \ +-object iothread,id=iothread2 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device virtio-scsi-pci,iothread=iothread2,id=scsi0,bus=pci.0,addr=0xb \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-drive file=/var/lib/libvirt/images/iothrtest1.img,format=raw,if=none,\ +id=drive-virtio-disk1 \ +-device virtio-blk-pci,iothread=iothread1,bus=pci.0,addr=0x4,\ +drive=drive-virtio-disk1,id=virtio-disk1 \ +-drive file=/var/lib/libvirt/images/iothrtest2.img,format=raw,if=none,\ +id=drive-scsi0-0-0-3 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=3,drive=drive-scsi0-0-0-3,\ +id=scsi0-0-0-3 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fc389c6..e41444d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1257,6 +1257,12 @@ mymain(void) DO_TEST("iothreads-disk", QEMU_CAPS_OBJECT_IOTHREAD); DO_TEST("iothreads-disk-virtio-ccw", QEMU_CAPS_OBJECT_IOTHREAD, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("iothreads-virtio-scsi-pci", QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_OBJECT_IOTHREAD, + QEMU_CAPS_VIRTIO_SCSI_IOTHREAD); + DO_TEST("iothreads-virtio-scsi-ccw", QEMU_CAPS_OBJECT_IOTHREAD, + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, + QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST("cpu-topology1", QEMU_CAPS_SMP_TOPOLOGY); DO_TEST("cpu-topology2", QEMU_CAPS_SMP_TOPOLOGY); -- 2.5.5

On 05/03/2016 02:42 PM, John Ferlan wrote:
v1 here: http://www.redhat.com/archives/libvir-list/2016-May/msg00077.html (patches 1-4 were pushed already, the following are patches 5-7)
Changes:
Patch 1: - Clean up docs, use 1.3.5 as the version instead of 1.3.4. - Use post parse callback virDomainDeviceDefPostParseInternal to handle the controller check if iothread's are set on a controller (rather than during Controller Def parsing
Patch 2: - Clean up commit message - Use the _() for message - Use 'target' not 'dst' in message (more specific)
Patch 3: - No changes
John Ferlan (3): conf: Add support for virtio-scsi iothreads qemu: Use switch for qemuCheckIOThreads qemu: Add 'iothread' to command line for supported controller
ACK series - Cole
participants (2)
-
Cole Robinson
-
John Ferlan