]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
hw/pci-bridge: fix QEMU crash because of pcie-root-port
authorMarcel Apfelbaum <marcel@redhat.com>
Wed, 10 Jan 2018 19:09:09 +0000 (21:09 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 23 Jan 2018 22:45:21 +0000 (16:45 -0600)
If we try to use more pcie_root_ports then available slots
and an IO hint is passed to the port, QEMU crashes because
we try to init the "IO hint" capability even if the device
is not created.
Fix it by checking for error before adding the capability,
so QEMU can fail gracefully.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit fced4d00e68e7559c73746d963265f7fd0b6abf9)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/pci-bridge/gen_pcie_root_port.c

index ad4e6aa7ffff77bc312ef7e5ac5de47d12351b75..0e2f2e8bf1a9a289f068fbd4f3b5664218602a00 100644 (file)
@@ -74,8 +74,13 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
     PCIDevice *d = PCI_DEVICE(dev);
     GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
     PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
+    Error *local_err = NULL;
 
-    rpc->parent_realize(dev, errp);
+    rpc->parent_realize(dev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
     int rc = pci_bridge_qemu_reserve_cap_init(d, 0, grp->bus_reserve,
             grp->io_reserve, grp->mem_reserve, grp->pref32_reserve,