aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2014-09-26 09:28:20 +0000
committerAndreas Färber <afaerber@suse.de>2014-10-15 05:03:13 +0200
commit181a2c63236966b3c80eef131bac33a355a492da (patch)
treed56e099a5191945d0185d1f8f1df3db4779b1b54 /hw/core/qdev.c
parent14d5a28fb6bb8ac6505ad1faca2690df56fef326 (diff)
qdev: HotplugHandler: Provide unplug callback
It is to be called for actual device removal and will allow to separate request and removal handling phases of x86-CPU devices and also it's a handler to be called for synchronously removable devices. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c13
1 files changed, 11 insertions, 2 deletions
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 */