[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 3/3] pci hotplug: make pci hotplug return value t
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH v2 3/3] pci hotplug: make pci hotplug return value to caller. |
Date: |
Tue, 22 Jun 2010 11:55:35 +0900 |
make pci hotplug callback return value to caller.
And when returning error, allocated resources are freed.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 75acbd3..76418c5 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1626,8 +1626,16 @@ 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 rc1 = pci_unregister_device(&pci_dev->qdev);
+ if (rc1) {
+ error_report("pci_unregister_device failed in
pci_qdev_init.\n");
+ }
+ return rc;
+ }
+ }
return 0;
}
@@ -1635,8 +1643,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)
--
1.6.6.1