summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/core/hotplug.c11
-rw-r--r--hw/core/qdev.c13
2 files changed, 22 insertions, 2 deletions
diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
index 2ec4736593..4e01074557 100644
--- a/hw/core/hotplug.c
+++ b/hw/core/hotplug.c
@@ -34,6 +34,17 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
}
}
+void hotplug_handler_unplug(HotplugHandler *plug_handler,
+ DeviceState *plugged_dev,
+ Error **errp)
+{
+ HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
+
+ if (hdc->unplug) {
+ hdc->unplug(plug_handler, plugged_dev, errp);
+ }
+}
+
static const TypeInfo hotplug_handler_info = {
.name = TYPE_HOTPLUG_HANDLER,
.parent = TYPE_INTERFACE,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 87ed438475..6479194498 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -227,8 +227,17 @@ void qdev_unplug(DeviceState *dev, Error **errp)
qdev_hot_removed = true;
if (dev->parent_bus && dev->parent_bus->hotplug_handler) {
- hotplug_handler_unplug_request(dev->parent_bus->hotplug_handler,
- dev, errp);
+ HotplugHandlerClass *hdc;
+
+ /* If device supports async unplug just request it to be done,
+ * otherwise just remove it synchronously */
+ hdc = HOTPLUG_HANDLER_GET_CLASS(dev->parent_bus->hotplug_handler);
+ if (hdc->unplug_request) {
+ hotplug_handler_unplug_request(dev->parent_bus->hotplug_handler,
+ dev, errp);
+ } else {
+ hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp);
+ }
} else {
assert(dc->unplug != NULL);
if (dc->unplug(dev) < 0) { /* legacy handler */