summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2014-06-02 15:25:03 +0200
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 16:41:46 +0300
commitb74545481187945965cf9f4df70b71d2f6cded4a (patch)
tree66b02a99a870635ec2cbd673887b2981eef194fe /hw
parentc270fb9eff1290e8a4a49040eba1305fec2ce0ec (diff)
downloadqemu-b74545481187945965cf9f4df70b71d2f6cded4a.tar.gz
qdev: hotplug for bus-less devices
Add get_hotplug_handler() method to machine, and make bus-less device use it during hotplug as a means to discover a hotplug handler controller. The returned controller is used to perform hotplug actions. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/core/qdev.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index e65a5aa3a8..fded64575d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -34,6 +34,7 @@
#include "qapi/qmp/qjson.h"
#include "monitor/monitor.h"
#include "hw/hotplug.h"
+#include "hw/boards.h"
int qdev_hotplug = 0;
static bool qdev_hot_added = false;
@@ -813,6 +814,18 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
local_err == NULL) {
hotplug_handler_plug(dev->parent_bus->hotplug_handler,
dev, &local_err);
+ } else if (local_err == NULL &&
+ object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
+ HotplugHandler *hotplug_ctrl;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (mc->get_hotplug_handler) {
+ hotplug_ctrl = mc->get_hotplug_handler(machine, dev);
+ if (hotplug_ctrl) {
+ hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
+ }
+ }
}
if (qdev_get_vmsd(dev) && local_err == NULL) {