[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL for-2.0-rc0 29/31] qdev: Realize buses on device real
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL for-2.0-rc0 29/31] qdev: Realize buses on device realization |
Date: |
Wed, 12 Mar 2014 22:10:01 +0100 |
From: Bandan Das <address@hidden>
Integrate (un)realization of child buses with realization/unrealization
of the device hosting them. Code in device_unparent() is reordered for
unrealization of buses to work as part of device unrealization.
That way no changes need to be made to bus instantiation.
Signed-off-by: Bandan Das <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/core/qdev.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 7e58259..9f0a522 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -716,6 +716,7 @@ static void device_set_realized(Object *obj, bool value,
Error **err)
{
DeviceState *dev = DEVICE(obj);
DeviceClass *dc = DEVICE_GET_CLASS(dev);
+ BusState *bus;
Error *local_err = NULL;
if (dev->hotplugged && !dc->hotpluggable) {
@@ -749,14 +750,30 @@ static void device_set_realized(Object *obj, bool value,
Error **err)
dev->instance_id_alias,
dev->alias_required_for_version);
}
+ if (local_err == NULL) {
+ QLIST_FOREACH(bus, &dev->child_bus, sibling) {
+ object_property_set_bool(OBJECT(bus), true, "realized",
+ &local_err);
+ if (local_err != NULL) {
+ break;
+ }
+ }
+ }
if (dev->hotplugged && local_err == NULL) {
device_reset(dev);
}
} else if (!value && dev->realized) {
- if (qdev_get_vmsd(dev)) {
+ QLIST_FOREACH(bus, &dev->child_bus, sibling) {
+ object_property_set_bool(OBJECT(bus), false, "realized",
+ &local_err);
+ if (local_err != NULL) {
+ break;
+ }
+ }
+ if (qdev_get_vmsd(dev) && local_err == NULL) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
- if (dc->unrealize) {
+ if (dc->unrealize && local_err == NULL) {
dc->unrealize(dev, &local_err);
}
}
@@ -841,13 +858,13 @@ static void device_unparent(Object *obj)
QObject *event_data;
bool have_realized = dev->realized;
+ if (dev->realized) {
+ object_property_set_bool(obj, false, "realized", NULL);
+ }
while (dev->num_child_bus) {
bus = QLIST_FIRST(&dev->child_bus);
object_unparent(OBJECT(bus));
}
- if (dev->realized) {
- object_property_set_bool(obj, false, "realized", NULL);
- }
if (dev->parent_bus) {
bus_remove_child(dev->parent_bus, dev);
object_unref(OBJECT(dev->parent_bus));
--
1.8.4.5
- [Qemu-devel] [PULL for-2.0-rc0 14/31] hw/core: Introduce QEMU machine as QOM object, (continued)
- [Qemu-devel] [PULL for-2.0-rc0 14/31] hw/core: Introduce QEMU machine as QOM object, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 19/31] tests: Add virtio-blk qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 27/31] tests: Add spapr-pci-host-bridge qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 21/31] tests: Add virtio-rng qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 18/31] tests: Clean up IndustryPack TPCI200 gcov paths, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 23/31] tests: Add virtio-serial qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 16/31] hw/boards: Convert current_machine to MachineState, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 25/31] virtio-console: QOM cast cleanup for VirtConsole, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 24/31] tests: Add virtio-console qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 26/31] virtio-serial-port: Convert to QOM realize/unrealize, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 29/31] qdev: Realize buses on device realization,
Andreas Färber <=
- [Qemu-devel] [PULL for-2.0-rc0 22/31] tests: Add virtio-scsi qtest, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 31/31] libqtest: Fix possible deadlock in qtest initialization, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 30/31] pci: Move VMState registration/unregistration to QOM realize/unrealize, Andreas Färber, 2014/03/12
- [Qemu-devel] [PULL for-2.0-rc0 28/31] qdev: Prepare realize/unrealize hooks for BusState, Andreas Färber, 2014/03/12
- Re: [Qemu-devel] [PULL for-2.0-rc0 00/31] QOM devices patch queue 2014-03-12, Peter Maydell, 2014/03/12