[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/10] qdev: finalize of qbus, qdev will not the rig
From: |
Liu Ping Fan |
Subject: |
[Qemu-devel] [PATCH 05/10] qdev: finalize of qbus, qdev will not the right place to free children |
Date: |
Fri, 24 Aug 2012 17:49:18 +0800 |
From: Liu Ping Fan <address@hidden>
When breaking big lock, the child object can be hold by mmio-dispatch,
and it is not right to free them when their parent gone.
We will isolate and release the children by qdev_delete_subtree(),
and let each object manage its own life cycle.
Signed-off-by: Liu Ping Fan <address@hidden>
---
hw/qdev.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 570f0bf..d6c8130 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -756,10 +756,8 @@ static void device_finalize(Object *obj)
DeviceClass *dc = DEVICE_GET_CLASS(dev);
if (dev->state == DEV_STATE_INITIALIZED) {
- while (dev->num_child_bus) {
- bus = QLIST_FIRST(&dev->child_bus);
- qbus_free(bus);
- }
+
+ g_assert(QLIST_EMPTY(&dev->child_bus));
if (qdev_get_vmsd(dev)) {
vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
}
@@ -770,9 +768,8 @@ static void device_finalize(Object *obj)
qemu_opts_del(dev->opts);
}
}
- if (dev->parent_bus) {
- bus_remove_child(dev->parent_bus, dev);
- }
+
+ g_assert((dev->parent_bus == NULL));
}
static void device_class_base_init(ObjectClass *class, void *data)
@@ -826,19 +823,16 @@ static void qbus_initfn(Object *obj)
static void qbus_finalize(Object *obj)
{
BusState *bus = BUS(obj);
- BusChild *kid;
- while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) {
- DeviceState *dev = kid->child;
- qdev_free(dev);
- }
- if (bus->parent) {
- QLIST_REMOVE(bus, sibling);
- bus->parent->num_child_bus--;
- } else {
- assert(bus != sysbus_get_default()); /* main_system_bus is never freed
*/
- qemu_unregister_reset(qbus_reset_all_fn, bus);
+ assert(bus != sysbus_get_default()); /* main_system_bus is never freed */
+ /* just blind check, since bus->parent has been set to NULL */
+ qemu_unregister_reset(qbus_reset_all_fn, bus);
+ if (bus->overlap != NULL) {
+ object_unref(OBJECT(bus->overlap));
}
+ assert(QTAILQ_EMPTY(&bus->children));
+ /* have reset it to NULL, to prevent reader */
+ assert((bus->parent == NULL));
g_free((char *)bus->name);
}
--
1.7.4.4
- [Qemu-devel] [PATCH 0/10] rework on hot unplug, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 01/10] qom: add, remove of link property need to ref, unref its target, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 02/10] qdev: change iterator callback seq, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 03/10] qom: export object_property_is_child, object_property_is_link, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 04/10] qdev: introduce new interface to remove composite sub-tree, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 05/10] qdev: finalize of qbus, qdev will not the right place to free children,
Liu Ping Fan <=
- [Qemu-devel] [PATCH 06/10] qom: expose object_property_del_child, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 07/10] unplug: using new intf qdev_delete_subtree in acpi_piix_eject_slot, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 09/10] mon: release dev's ref hold by qdev_get_peripheral, Liu Ping Fan, 2012/08/24
- [Qemu-devel] [PATCH 10/10] qdev: fix create in place obj's life cycle problem, Liu Ping Fan, 2012/08/24