[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [RFC PATCH 02/15] qdev: store DeviceState's canonical pat
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-ppc] [RFC PATCH 02/15] qdev: store DeviceState's canonical path to use when unparenting |
Date: |
Thu, 30 Apr 2015 15:35:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 29/04/2015 21:20, Michael Roth wrote:
> If the parent is finalized as a result of object_unparent(), it
> will still be attached to the composition tree at the time any
> children are unparented as a result of that same call to
> object_unparent(). However, in some cases, object_unparent()
> will complete without finalizing the parent device, due to
> lingering references that won't be released till some time later.
> One such example is if the parent has MemoryRegion children (which
> take a ref on their parent), who in turn have AddressSpace's (which
> take a ref on their regions), since those AddressSpaces get cleaned
> up asynchronously by the RCU thread.
>
> In this case qdev:device_unparent() may be called for a child Device
> that no longer has a path to the root/machine container, causing
> object_get_canonical_path() to assert.
This doesn't seem right. Unparent callbacks are _not_ called when you
finalize, they are called in post-order as soon as you unplug a device
(the call tree is object_unparent ==> device_unparent(parent) ==>
bus_unparent(parent->bus) ==> device_unparent(parent->bus->child[0])
and so on).
DEVICE_DELETED is called after a device's children have been
unparented. It could be called after a bus is dead though. Could it
be that the patch you want is simply this:
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6e6a65d..46019c4 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -1241,11 +1241,6 @@ static void device_unparent(Object *obj)
bus = QLIST_FIRST(&dev->child_bus);
object_unparent(OBJECT(bus));
}
- if (dev->parent_bus) {
- bus_remove_child(dev->parent_bus, dev);
- object_unref(OBJECT(dev->parent_bus));
- dev->parent_bus = NULL;
- }
/* Only send event if the device had been completely realized */
if (dev->pending_deleted_event) {
@@ -1254,6 +1249,12 @@ static void device_unparent(Object *obj)
qapi_event_send_device_deleted(!!dev->id, dev->id, path, &error_abort);
g_free(path);
}
+
+ if (dev->parent_bus) {
+ bus_remove_child(dev->parent_bus, dev);
+ object_unref(OBJECT(dev->parent_bus));
+ dev->parent_bus = NULL;
+ }
}
static void device_class_init(ObjectClass *class, void *data)
?
Paolo
- [Qemu-ppc] [RFC PATCH 09/15] spapr: populate PHB DRC entries for root DT node, (continued)
- [Qemu-ppc] [RFC PATCH 09/15] spapr: populate PHB DRC entries for root DT node, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 10/15] spapr_events: add support for phb hotplug events, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 11/15] qdev: add qbus_set_hotplug_handler_generic(), Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 14/15] spapr_pci: add ibm, my-drc-index property for PHB hotplug, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 12/15] spapr: stub implementation of machine-level HotplugHandler interface, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 13/15] spapr_pci: provide node start offset via spapr_populate_pci_dt(), Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 01/15] pci: allow cleanup/unregistration of PCI buses, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 15/15] spapr: add hotplug hooks for PHB hotplug, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 02/15] qdev: store DeviceState's canonical path to use when unparenting, Michael Roth, 2015/04/29
- Re: [Qemu-ppc] [RFC PATCH 02/15] qdev: store DeviceState's canonical path to use when unparenting,
Paolo Bonzini <=
- [Qemu-ppc] [RFC PATCH 05/15] spapr_pci: add PHB unrealize, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 03/15] spapr_drc: pass object ownership to parent/owner, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 04/15] spapr_iommu: pass object ownership to parent/owner, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 06/15] spapr_pci: also use 'index' property as DRC index for PHBs, Michael Roth, 2015/04/29
- [Qemu-ppc] [RFC PATCH 07/15] spapr: enable PHB hotplug for pseries-2.4, Michael Roth, 2015/04/29