]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: auto-add a USB2 controller set for Q35 machines
authorLaine Stump <laine@laine.org>
Tue, 20 Oct 2015 16:08:56 +0000 (12:08 -0400)
committerLaine Stump <laine@laine.org>
Mon, 11 Jan 2016 18:21:10 +0000 (13:21 -0500)
Use virDomainDefAddUSBController() to add an EHCI1+UHCI1+UHCI2+UHCI3
controller set to newly defined Q35 domains that don't have any USB
controllers defined.

src/qemu/qemu_domain.c
tests/qemuxml2argvdata/qemuxml2argv-q35.args
tests/qemuxml2argvtest.c

index e8c291fc6748c690d72d447ea5a5b91671c7d3ff..0fa2dbeb40e1a534c960a8fe349c7106b3715cc7 100644 (file)
@@ -1039,6 +1039,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
                                virQEMUCapsPtr qemuCaps)
 {
     bool addDefaultUSB = true;
+    int usbModel = -1; /* "default for machinetype" */
     bool addImplicitSATA = false;
     bool addPCIRoot = false;
     bool addPCIeRoot = false;
@@ -1061,8 +1062,15 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
         if (STRPREFIX(def->os.machine, "pc-q35") ||
             STREQ(def->os.machine, "q35")) {
             addPCIeRoot = true;
-            addDefaultUSB = false;
             addImplicitSATA = true;
+
+            /* add a USB2 controller set, but only if the
+             * ich9-usb-ehci1 device is supported
+             */
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1))
+                usbModel = VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1;
+            else
+                addDefaultUSB = false;
             break;
         }
         if (!STRPREFIX(def->os.machine, "pc-0.") &&
@@ -1120,8 +1128,8 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
     }
 
     if (addDefaultUSB &&
-        virDomainDefMaybeAddController(
-            def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
+        virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0 &&
+        virDomainDefAddUSBController(def, 0, usbModel) < 0)
         goto cleanup;
 
     if (addImplicitSATA &&
index efe6e69cf98e26a20c6c7859bd521b2f63dd97e9..4867eac040d36f5d22fdcb242384ba5f45f71ba4 100644 (file)
@@ -18,6 +18,11 @@ QEMU_AUDIO_DRV=none \
 -boot c \
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
 -device pci-bridge,chassis_nr=56,id=pci.2,bus=pci.1,addr=0x1 \
+-device ich9-usb-ehci1,id=usb,bus=pcie.0,addr=0x1d.0x7 \
+-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pcie.0,multifunction=on,\
+addr=0x1d \
+-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \
+-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pcie.0,addr=0x1d.0x2 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \
 -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
 -vga qxl \
index f746b1b2c6fd19d527440617839ceba1c51d6746..20998324a6bf75dd115bbcbfe895b0cf000c5ee3 100644 (file)
@@ -1504,6 +1504,7 @@ mymain(void)
             QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_ICH9_AHCI,
+            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
     DO_TEST("q35-pm-disable",