aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-12-10 11:11:06 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-12 08:17:30 -0600
commitea2138cf90fd4c2a6fefabff23b4c8681411a3f0 (patch)
treeee9ab5c5a77ec4b7aceea19a082a85dc533f31c5
parentpci: don't abort() when trying to hotplug with acpi off. (diff)
downloadqemu-kvm-ea2138cf90fd4c2a6fefabff23b4c8681411a3f0.tar.gz
qemu-kvm-ea2138cf90fd4c2a6fefabff23b4c8681411a3f0.tar.bz2
qemu-kvm-ea2138cf90fd4c2a6fefabff23b4c8681411a3f0.zip
pci: don't hw_error() when no slot is available.
Current PCI code will simply hw_error() and thus abort in case no free PCI slot is available or the requested PCI slot is already in use by another device. For the hotplug case this behavior is not acceptable. This patch makes qemu pass up the error properly, so the calling code can decide whenever it wants to exit with an error (on startup) or whenever it wants to continue (hotplug). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 09e3acc6cfabfd85a9dacc04471df5f05019c779)
-rw-r--r--hw/pci.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 4f662b769..404eead58 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -580,11 +580,13 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
if (!bus->devices[devfn])
goto found;
}
- hw_error("PCI: no devfn available for %s, all in use\n", name);
+ qemu_error("PCI: no devfn available for %s, all in use\n", name);
+ return NULL;
found: ;
} else if (bus->devices[devfn]) {
- hw_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
+ qemu_error("PCI: devfn %d not available for %s, in use by %s\n", devfn,
name, bus->devices[devfn]->name);
+ return NULL;
}
pci_dev->bus = bus;
pci_dev->devfn = devfn;
@@ -625,6 +627,9 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name,
pci_dev = do_pci_register_device(pci_dev, bus, name, devfn,
config_read, config_write,
PCI_HEADER_TYPE_NORMAL);
+ if (pci_dev == NULL) {
+ hw_error("PCI: can't register device\n");
+ }
return pci_dev;
}
static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
@@ -1376,6 +1381,8 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
pci_dev = do_pci_register_device(pci_dev, bus, base->name, devfn,
info->config_read, info->config_write,
info->header_type);
+ if (pci_dev == NULL)
+ return -1;
rc = info->init(pci_dev);
if (rc != 0)
return rc;