]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add check for PCI bridge placement if there are too many PCI devices
authorErik Skultety <eskultet@redhat.com>
Fri, 23 Jan 2015 12:17:43 +0000 (13:17 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 23 Jan 2015 13:35:03 +0000 (14:35 +0100)
Previous patch of this series fixed the issue with adding a new PCI bridge
when all the slots were reserved by devices with user specified addresses.
In case there are still some PCI devices waiting to get a slot reserved
by qemuAssignDevicePCISlots, this means a new bus needs to be
created along with a corresponding bridge controller. By adding an
additional check, this scenario now results in a reasonable error
instead of generating wrong qemu command line.

src/qemu/qemu_command.c

index e598430d2d9fc31bb2283d4446451ad335538c79..e793b7e51a31dd62b1ad94c38d8ab431568253e9 100644 (file)
@@ -1981,6 +1981,25 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
 
             if (qemuAssignDevicePCISlots(def, addrs) < 0)
                 goto cleanup;
+
+            for (i = 0; i < def->ncontrollers; i++) {
+                /* check if every PCI bridge controller's ID is greater than
+                 * the bus it is placed onto
+                 */
+                virDomainControllerDefPtr cont = def->controllers[i];
+                int idx = cont->idx;
+                int bus = cont->info.addr.pci.bus;
+                if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+                    cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE &&
+                    idx <= bus) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("failed to create PCI bridge "
+                                     "on bus %d: too many devices with fixed "
+                                     "addresses"),
+                                   bus);
+                    goto cleanup;
+                }
+            }
         }
     }