aboutsummaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2010-06-22 11:55:35 +0900
committerMichael S. Tsirkin <mst@redhat.com>2010-07-11 23:31:52 +0300
commita213ff63ead450c3bf3b47497681a1498570fcdd (patch)
tree4e045527d666ff2349f9af95bd116cdd0bfb7daf /hw/pci.c
parentbd57ce8c7b3ab2c74335947e69f1eabc73fae438 (diff)
pci hotplug: make pci hotplug return value to caller
make pci hotplug callback return value to caller. And when returning error, allocated resources are freed. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 645506aa83..fbba6e38fe 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1693,8 +1693,14 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
pci_dev->romfile = qemu_strdup(info->romfile);
pci_add_option_rom(pci_dev);
- if (qdev->hotplugged)
- bus->hotplug(bus->hotplug_qdev, pci_dev, 1);
+ if (qdev->hotplugged) {
+ rc = bus->hotplug(bus->hotplug_qdev, pci_dev, 1);
+ if (rc != 0) {
+ int r = pci_unregister_device(&pci_dev->qdev);
+ assert(!r);
+ return rc;
+ }
+ }
return 0;
}
@@ -1702,8 +1708,7 @@ static int pci_unplug_device(DeviceState *qdev)
{
PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
- dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0);
- return 0;
+ return dev->bus->hotplug(dev->bus->hotplug_qdev, dev, 0);
}
void pci_qdev_register(PCIDeviceInfo *info)