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 <jfer...@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 4d37410..f7ddbee 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2178,6 +2178,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,
@@ -2225,16 +2284,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 1d13c05..cf0a438 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1254,6 +1254,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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to