Skip to content

Commit

Permalink
qdev: Add wrapper to set BUS as HotplugHandler
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Igor Mammedov authored and afaerber committed Oct 15, 2014
1 parent 014176f commit 431bbb2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
19 changes: 19 additions & 0 deletions hw/core/qdev.c
Expand Up @@ -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. */
Expand Down
11 changes: 4 additions & 7 deletions include/hw/qdev-core.h
Expand Up @@ -363,13 +363,10 @@ extern int qdev_hotplug;

char *qdev_get_dev_path(DeviceState *dev);

static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *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);

void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp);

static inline bool qbus_is_hotpluggable(BusState *bus)
{
Expand Down

0 comments on commit 431bbb2

Please sign in to comment.