[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/47] qdev: HotplugHandler: Provide unplug callback
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 20/47] qdev: HotplugHandler: Provide unplug callback |
Date: |
Wed, 15 Oct 2014 05:08:54 +0200 |
From: Igor Mammedov <address@hidden>
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 <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/core/hotplug.c | 11 +++++++++++
hw/core/qdev.c | 13 +++++++++++--
include/hw/hotplug.h | 12 ++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
index 2ec4736..4e01074 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 87ed438..6479194 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 */
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index e397d08..050d2f0 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -50,6 +50,9 @@ typedef void (*hotplug_fn)(HotplugHandler *plug_handler,
* @unplug_request: unplug request callback.
* Used as a means to initiate device unplug for devices that
* require asynchronous unplug handling.
+ * @unplug: unplug callback.
+ * Used for device removal with devices that implement
+ * asynchronous and synchronous (suprise) removal.
*/
typedef struct HotplugHandlerClass {
/* <private> */
@@ -58,6 +61,7 @@ typedef struct HotplugHandlerClass {
/* <public> */
hotplug_fn plug;
hotplug_fn unplug_request;
+ hotplug_fn unplug;
} HotplugHandlerClass;
/**
@@ -77,4 +81,12 @@ void hotplug_handler_plug(HotplugHandler *plug_handler,
void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
DeviceState *plugged_dev,
Error **errp);
+/**
+ * hotplug_handler_unplug:
+ *
+ * Calls #HotplugHandlerClass.unplug callback of @plug_handler.
+ */
+void hotplug_handler_unplug(HotplugHandler *plug_handler,
+ DeviceState *plugged_dev,
+ Error **errp);
#endif
--
1.8.4.5
- [Qemu-devel] [PULL 08/47] libqos: Add qpci_plug_device_test() and qpci_unplug_acpi_device_test(), (continued)
- [Qemu-devel] [PULL 08/47] libqos: Add qpci_plug_device_test() and qpci_unplug_acpi_device_test(), Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 09/47] tests: virtio-rng: Check if hot-plug/unplug works, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 05/47] qom: Add error handler for object alias property, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 11/47] tests: virtio-blk: Check if hot-plug/unplug works, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 10/47] tests: virtio-net: Check if hot-plug/unplug works, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 13/47] tests: usb: add port test to uhci unit test, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 16/47] tests: usb: usb-uas hotplug test, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 12/47] tests: usb: Move uhci port test code to libqos/usb.c, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 19/47] qdev: HotplugHandler: Rename unplug callback to unplug_request, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 14/47] tests: usb: Generic usb device hotplug, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 20/47] qdev: HotplugHandler: Provide unplug callback,
Andreas Färber <=
- [Qemu-devel] [PULL 15/47] tests: usb: usb-storage hotplug test, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 21/47] qdev: Add simple/generic unplug callback for HotplugHandler, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 17/47] Access BusState::allow_hotplug using wraper qbus_is_hotpluggable(), Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 18/47] qdev: do not allow to instantiate non hotpluggable device with device_add, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 23/47] qdev: Drop hotplug check from bus_add_child(), Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 22/47] qdev: Add wrapper to set BUS as HotplugHandler, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 24/47] target-i386: ICC bus: Drop BusState::allow_hotplug, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 25/47] virtio-pci: Drop BusState::allow_hotplug, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 27/47] virtio-mmio: Drop useless bus->allow_hotplug = 0, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 29/47] s390x: Convert s390-virtio to hotplug handler API, Andreas Färber, 2014/10/14