]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix USB model defaults for ppc64
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 7 Jan 2016 15:14:58 +0000 (16:14 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Sat, 9 Jan 2016 17:39:17 +0000 (18:39 +0100)
The condition was checking for UHCI (and OHCI for ppc64) availability so
that it can specify the proper device instead of legacy usb.  However,
for ppc64, we don't need to check both OHCI and UHCI, but only OHCI as
that is the legacy default.  The condition is so big that it was just a
matter of time when someone will make a mistake there, so let's use more
lines so that it is visible what the condition checks for.

This fixes usage of -device instead of -usb for ppc64 that supports
pci-usb-ohci and does not support piix3-usb-uhci.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1297020

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.xml [new symlink]
tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 1f0593526b55d792ee237c3a6d3e874cd85f7e21..aa7efb301d08f86d66242eba901a57bf4d121f01 100644 (file)
@@ -10049,18 +10049,30 @@ qemuBuildCommandLine(virConnectPtr conn,
 
                 if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
                     cont->model == -1 &&
-                    !qemuDomainMachineIsQ35(def) &&
-                    (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI) ||
-                     (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI) &&
-                      ARCH_IS_PPC64(def->os.arch)))) {
-                    if (usblegacy) {
-                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                       _("Multiple legacy USB controllers are "
-                                         "not supported"));
-                        goto error;
+                    !qemuDomainMachineIsQ35(def)) {
+                    bool need_legacy = false;
+
+                    /* We're not using legacy usb controller for q35 */
+                    if (ARCH_IS_PPC64(def->os.arch)) {
+                        /* For ppc64 the legacy was OHCI */
+                        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
+                            need_legacy = true;
+                    } else {
+                        /* For anything else, we used PIIX3_USB_UHCI */
+                        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
+                            need_legacy = true;
+                    }
+
+                    if (need_legacy) {
+                        if (usblegacy) {
+                            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                           _("Multiple legacy USB controllers are "
+                                             "not supported"));
+                            goto error;
+                        }
+                        usblegacy = true;
+                        continue;
                     }
-                    usblegacy = true;
-                    continue;
                 }
 
                 virCommandAddArg(cmd, "-device");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.args
new file mode 100644 (file)
index 0000000..7d301f3
--- /dev/null
@@ -0,0 +1,19 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/libexec/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-S \
+-M pseries \
+-m 256 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-boot c \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci,addr=0x6
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.xml b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-legacy.xml
new file mode 120000 (symlink)
index 0000000..831d9d4
--- /dev/null
@@ -0,0 +1 @@
+qemuxml2argv-ppc64-usb-controller.xml
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.args
new file mode 100644 (file)
index 0000000..f17a377
--- /dev/null
@@ -0,0 +1,19 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/libexec/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-S \
+-M pseries \
+-m 256 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-boot c \
+-device pci-ohci,id=usb,bus=pci,addr=0x1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci,addr=0x6
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.xml b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller.xml
new file mode 100644 (file)
index 0000000..ce180ee
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/libexec/qemu-system-ppc64</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </memballoon>
+  </devices>
+</domain>
index b023522e69f71d2e9f97b8b144c7a5b21f696c59..0468dbf740195a4810249a00e6e3fbf0f19d4e39 100644 (file)
@@ -1779,6 +1779,11 @@ mymain(void)
             QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
     DO_TEST("virtio-input-passthrough", QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_INPUT_HOST);
 
+    DO_TEST("ppc64-usb-controller",
+            QEMU_CAPS_DEVICE, QEMU_CAPS_PCI_OHCI);
+    DO_TEST("ppc64-usb-controller-legacy",
+            QEMU_CAPS_DEVICE, QEMU_CAPS_PIIX3_USB_UHCI);
+
     qemuTestDriverFree(&driver);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;