]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: don't assume slot 0 is unused/reserved.
authorLaine Stump <laine@laine.org>
Wed, 21 Oct 2015 18:49:06 +0000 (14:49 -0400)
committerLaine Stump <laine@laine.org>
Mon, 11 Jan 2016 17:58:40 +0000 (12:58 -0500)
When qemuAssignDevicePCISlots() is looking for companion controllers
for a USB controller that has no PCI address specified, it initializes
a virDevicePCIAddress to 0000:00:00.0, fills it in with the
companion's address if one is found, then checks whether or not there
was a find based on slot == 0. On a system with a single PCI bus, that
is a valid way to check, because slot 0 is reserved, but on most other
PCI buses, slot 0 is not reserved, and is open for use by any
device. This patch adds a separate bool that is set when a companion
is found rather than relying on the faulty information provided with
"slot == 0".

src/qemu/qemu_command.c

index e711f3031a3e1b0894292002616da1c19d613de5..15d2355904fe11f4125af4881025516fcf8f83e3 100644 (file)
@@ -2538,11 +2538,14 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
         /* USB2 needs special handling to put all companions in the same slot */
         if (IS_USB2_CONTROLLER(def->controllers[i])) {
             virDevicePCIAddress addr = { 0, 0, 0, 0, false };
+            bool foundAddr = false;
+
             memset(&tmp_addr, 0, sizeof(tmp_addr));
             for (j = 0; j < i; j++) {
                 if (IS_USB2_CONTROLLER(def->controllers[j]) &&
                     def->controllers[j]->idx == def->controllers[i]->idx) {
                     addr = def->controllers[j]->info.addr.pci;
+                    foundAddr = true;
                     break;
                 }
             }
@@ -2563,7 +2566,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
                 break;
             }
 
-            if (addr.slot == 0) {
+            if (!foundAddr) {
                 /* This is the first part of the controller, so need
                  * to find a free slot & then reserve a function */
                 if (virDomainPCIAddressGetNextSlot(addrs, &tmp_addr, flags) < 0)