Patchwork [3/4] pci: Add force_unplug callback.

login
register
mail settings
Submitter Anthony PERARD
Date May 15, 2012, 3:26 p.m.
Message ID <1337095599-28836-4-git-send-email-anthony.perard@citrix.com>
Download mbox | patch
Permalink /patch/159370/
State New
Headers show

Comments

Anthony PERARD - May 15, 2012, 3:26 p.m.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 hw/pci.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index b706e69..c58bbc1 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1518,7 +1518,7 @@  static int pci_qdev_init(DeviceState *qdev)
     return 0;
 }
 
-static int pci_unplug_device(DeviceState *qdev)
+static int pci_unplug_device_common(DeviceState *qdev, PCIHotplugState state)
 {
     PCIDevice *dev = PCI_DEVICE(qdev);
     PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
@@ -1529,7 +1529,17 @@  static int pci_unplug_device(DeviceState *qdev)
     }
     object_unparent(OBJECT(dev));
     return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
-                             PCI_HOTPLUG_DISABLED);
+                             state);
+}
+
+static int pci_unplug_device(DeviceState *qdev)
+{
+    return pci_unplug_device_common(qdev, PCI_HOTPLUG_DISABLED);
+}
+
+static int pci_force_unplug_device(DeviceState *qdev)
+{
+    return pci_unplug_device_common(qdev, PCI_FORCE_EJECT);
 }
 
 PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
@@ -2000,6 +2010,7 @@  static void pci_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = pci_qdev_init;
     k->unplug = pci_unplug_device;
+    k->force_unplug = pci_force_unplug_device;
     k->exit = pci_unregister_device;
     k->bus_info = &pci_bus_info;
 }