]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix usb master startport parsing
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 23 Apr 2013 14:23:51 +0000 (16:23 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 25 Apr 2013 12:54:46 +0000 (14:54 +0200)
When all usb controllers connected to the same bus have <master
startport='x'/> specified, none of them have 'id=usb' assigned and
thus qemu fails due to invalid masterport specification (we use 'usb'
for that purpose).  Adding a check that at least one of the
controllers is specified without <master startport='x'/> and in case
this happens, error out due to invalid configuration.

src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index cb691785c94abe2718342d58ed482ad6c52fe1fd..efeaa251d668fa365f1e521e423c7022c0d57c8e 100644 (file)
@@ -9930,6 +9930,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     xmlNodePtr cur;
     bool usb_none = false;
     bool usb_other = false;
+    bool usb_master = false;
     bool primaryVideo = false;
 
     if (VIR_ALLOC(def) < 0) {
@@ -10890,12 +10891,21 @@ virDomainDefParseXML(xmlDocPtr xml,
                 }
                 usb_other = true;
             }
+
+            if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE)
+                usb_master = true;
         }
 
         virDomainControllerInsertPreAlloced(def, controller);
     }
     VIR_FREE(nodes);
 
+    if (usb_other && !usb_master) {
+        virReportError(VIR_ERR_XML_DETAIL, "%s",
+                       _("No master USB controller specified"));
+        goto error;
+    }
+
     if (def->virtType == VIR_DOMAIN_VIRT_QEMU ||
         def->virtType == VIR_DOMAIN_VIRT_KQEMU ||
         def->virtType == VIR_DOMAIN_VIRT_KVM)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml
new file mode 100644 (file)
index 0000000..895d932
--- /dev/null
@@ -0,0 +1,21 @@
+<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>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0' model='ich9-uhci2'>
+      <master startport='2'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0'/>
+    </controller>
+    <memballoon model='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0'/>
+    </memballoon>
+  </devices>
+</domain>
index e4103ec19f1ddb64312d0f1fe28b521dd13781bf..25fa5b702a07756642f372330c3202d5eb471401 100644 (file)
@@ -768,6 +768,9 @@ mymain(void)
     DO_TEST("usb-ich9-companion",
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
+    DO_TEST_PARSE_ERROR("usb-ich9-no-companion",
+            QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1);
     DO_TEST("usb-hub",
             QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_USB_HUB,
             QEMU_CAPS_NODEFCONFIG);