summary refs log tree commit diff stats
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2014-09-26 09:28:22 +0000
committerAndreas Färber <afaerber@suse.de>2014-10-15 05:03:13 +0200
commit431bbb26cbd0e9862c48320deaaf83aa9aacd6ce (patch)
tree8e8aa8f8daa023deb8b85fbf70010cd709640a0d /hw/core/qdev.c
parent014176f914ab8e41a88225e8f26569ef0e0bf223 (diff)
downloadfocaccia-qemu-431bbb26cbd0e9862c48320deaaf83aa9aacd6ce.tar.gz
focaccia-qemu-431bbb26cbd0e9862c48320deaaf83aa9aacd6ce.zip
qdev: Add wrapper to set BUS as HotplugHandler
To be used for conversion of SCSI and USB devices,
and would allow to make every HBA/USB host switch
to HotplugHandler API without touching each controller
explicitly.

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.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9f18520219..b1da409eeb 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -112,6 +112,25 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
     bus_add_child(bus, dev);
 }
 
+static void qbus_set_hotplug_handler_internal(BusState *bus, Object *handler,
+                                              Error **errp)
+{
+
+    object_property_set_link(OBJECT(bus), OBJECT(handler),
+                             QDEV_HOTPLUG_HANDLER_PROPERTY, errp);
+    bus->allow_hotplug = 1;
+}
+
+void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, Error **errp)
+{
+    qbus_set_hotplug_handler_internal(bus, OBJECT(handler), errp);
+}
+
+void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp)
+{
+    qbus_set_hotplug_handler_internal(bus, OBJECT(bus), errp);
+}
+
 /* Create a new device.  This only initializes the device state structure
    and allows properties to be set.  qdev_init should be called to
    initialize the actual device emulation.  */