[PATCH v2] Fix usb master startport parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
v2:
 - Don't fix user/app errors, just error out.
---
 src/conf/domain_conf.c                              | 10 ++++++++++
 .../qemuxml2argv-usb-ich9-no-companion.xml          | 21 +++++++++++++++++++++
 tests/qemuxml2argvtest.c                            |  3 +++
 3 files changed, 34 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 958b77b..99d3232 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9913,6 +9913,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) {
@@ -10873,12 +10874,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_first && !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
index 0000000..895d932
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-no-companion.xml
@@ -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>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f40d002..abb3b27 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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_FAILURE("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);
--
1.8.2.1

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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]