diff options
author | Bandan Das | 2013-11-25 23:48:40 +0100 |
---|---|---|
committer | Andreas Färber | 2014-03-13 01:21:57 +0100 |
commit | 02e7f85dac3c639b70460ce557cb6c29963db97a (patch) | |
tree | c41999ae07075f934d0602098b58a13214c0be3e /hw/core | |
parent | tests: Add spapr-pci-host-bridge qtest (diff) | |
download | qemu-02e7f85dac3c639b70460ce557cb6c29963db97a.tar.gz qemu-02e7f85dac3c639b70460ce557cb6c29963db97a.tar.xz qemu-02e7f85dac3c639b70460ce557cb6c29963db97a.zip |
qdev: Prepare realize/unrealize hooks for BusState
Add a "realized" property calling realize/unrealize hooks as for devices.
Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/qdev.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 71b70454eb..7e58259911 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -501,6 +501,45 @@ static void bus_unparent(Object *obj) } } +static bool bus_get_realized(Object *obj, Error **err) +{ + BusState *bus = BUS(obj); + + return bus->realized; +} + +static void bus_set_realized(Object *obj, bool value, Error **err) +{ + BusState *bus = BUS(obj); + BusClass *bc = BUS_GET_CLASS(bus); + Error *local_err = NULL; + + if (value && !bus->realized) { + if (bc->realize) { + bc->realize(bus, &local_err); + + if (local_err != NULL) { + goto error; + } + + } + } else if (!value && bus->realized) { + if (bc->unrealize) { + bc->unrealize(bus, &local_err); + + if (local_err != NULL) { + goto error; + } + } + } + + bus->realized = value; + return; + +error: + error_propagate(err, local_err); +} + void qbus_create_inplace(void *bus, size_t size, const char *typename, DeviceState *parent, const char *name) { @@ -889,6 +928,8 @@ static void qbus_initfn(Object *obj) object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, TYPE_HOTPLUG_HANDLER, (Object **)&bus->hotplug_handler, NULL); + object_property_add_bool(obj, "realized", + bus_get_realized, bus_set_realized, NULL); } static char *default_bus_get_fw_dev_path(DeviceState *dev) |