From: Thomas Huth <[email protected]>

When trying to plug a PCI device to a Sparc64 machine, you currently
have to specify the right bus ("bus=pciB"), otherwise you get this error:

 $ qemu-system-sparc64 -device virtio-scsi-pci
 qemu-system-sparc64: -device virtio-scsi-pci: PCI: no slot/function
  available for virtio-scsi-pci, all in use or reserved

This is quite annoying for the unexperienced users, and it also breaks
e.g. the iotests ("make check-block") when running with qemu-system-sparc64.

Mark the non-usable PCI busses as full now, so that QEMU can automatically
plug new PCI devices to the right "pciB" bus.

Signed-off-by: Thomas Huth <[email protected]>
---
 Note: Only lightly tested, it seems to work fine for me at a first glance,
 but maybe I missed something...

 hw/pci-host/sabre.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/pci-host/sabre.c b/hw/pci-host/sabre.c
index cd2328ad53f..9c8519f3849 100644
--- a/hw/pci-host/sabre.c
+++ b/hw/pci-host/sabre.c
@@ -382,6 +382,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
                                      &s->pci_mmio,
                                      &s->pci_ioport,
                                      0, 0x40, TYPE_PCI_BUS);
+    qbus_mark_full(&phb->bus->qbus);
 
     pci_create_simple(phb->bus, 0, TYPE_SABRE_PCI_DEVICE);
 
@@ -400,6 +401,7 @@ static void sabre_realize(DeviceState *dev, Error **errp)
     s->bridgeA = PCI_BRIDGE(pci_dev);
     pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq);
     pci_realize_and_unref(pci_dev, phb->bus, &error_fatal);
+    qbus_mark_full(&s->bridgeA->sec_bus.qbus);
 }
 
 static void sabre_init(Object *obj)
-- 
2.53.0


Reply via email to