]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
domain-conf: reorder usb controllers so the master is first
authorPavel Hrdina <phrdina@redhat.com>
Wed, 11 Nov 2015 14:20:15 +0000 (15:20 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 11 Nov 2015 14:30:49 +0000 (15:30 +0100)
USB controllers can share the same 'index' which indicates, that there
is some sort of master-companion relationship.  Reorder the controllers
in XML in to place the master controller before its companions.  This is
required by QEMU to not fail with error message:

error: internal error: process exited while connecting to monitor:
2015-10-26T16:25:17.630265Z qemu-system-x86_64:
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6:
USB bus 'usb.0' not found

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index f9fb68338b4d9563216b9af1cab59a1582f7e0c8..eb0044449ab780c690fc4ede6c33a3d977f17364 100644 (file)
@@ -13412,6 +13412,14 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
                  * new controller, then new controller should go here
                  * */
                 insertAt = idx;
+            } else if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE &&
+                       current->info.mastertype != VIR_DOMAIN_CONTROLLER_MASTER_NONE &&
+                       current->idx == controller->idx) {
+                /* If bus matches and index matches and new controller is
+                 * master and current isn't a master, then new controller
+                 * should go here to be placed before its companion
+                 */
+                insertAt = idx;
             } else if (insertAt == -1) {
                 /* Last controller with match bus is before the
                  * new controller, then put new controller just after
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml b/tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml
new file mode 100644 (file)
index 0000000..6cc0f50
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='kvm'>
+  <name>rhel7</name>
+  <uuid>c9b867fb-7274-4a22-8884-0867d05b38cf</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <pm>
+    <suspend-to-mem enabled='no'/>
+    <suspend-to-disk enabled='no'/>
+  </pm>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0' model='ich9-uhci1'>
+      <master startport='0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
+    </controller>
+    <controller type='usb' index='0' model='ich9-ehci1'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7' multifunction='on'/>
+    </controller>
+    <controller type='usb' index='1' model='nec-xhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </controller>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml
new file mode 100644 (file)
index 0000000..a3c22e8
--- /dev/null
@@ -0,0 +1,34 @@
+<domain type='kvm'>
+  <name>rhel7</name>
+  <uuid>c9b867fb-7274-4a22-8884-0867d05b38cf</uuid>
+  <memory unit='KiB'>2097152</memory>
+  <currentMemory unit='KiB'>2097152</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <pm>
+    <suspend-to-mem enabled='no'/>
+    <suspend-to-disk enabled='no'/>
+  </pm>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <controller type='usb' index='0' model='ich9-ehci1'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7' multifunction='on'/>
+    </controller>
+    <controller type='usb' index='0' model='ich9-uhci1'>
+      <master startport='0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
+    </controller>
+    <controller type='usb' index='1' model='nec-xhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index 103fb79ae800d32f5d7a95dcdc093f15106b0d02..cbd4d0d1dd28a84518839bde142e87fc544a1cb4 100644 (file)
@@ -507,6 +507,7 @@ mymain(void)
     DO_TEST_DIFFERENT("usb-redir-filter");
     DO_TEST_DIFFERENT("usb-redir-filter-version");
     DO_TEST("blkdeviotune");
+    DO_TEST_DIFFERENT("controller-usb-order");
 
     DO_TEST_FULL("seclabel-dynamic-baselabel", false, WHEN_INACTIVE);
     DO_TEST_FULL("seclabel-dynamic-override", false, WHEN_INACTIVE);