On Thu, May 29, 2014 at 07:11:27PM +1000, Peter Crosthwaite wrote: > On Fri, May 23, 2014 at 1:40 AM, Stefan Hajnoczi <stefa...@redhat.com> wrote: > > object_initialize() leaves the object with a refcount of 1. > > object_property_add_child() adds its own reference which is dropped > > again when the property is deleted. > > > > The upshot of this is that we always have a refcount >= 1. Upon hot > > unplug the virtio-blk child is not finalized! > > > > Doesn't this suggest that hot unplug is what's broken? My > understanding (which is fresh and not 100% yet) is the original == 1 > refcount should be dropped at object deletion time which is this sense > would be unplug time. This would mean that hot-unplug should > explicitly object_unref the object (should the intention of hot-unplug > be to always finalise the device?).
We could add an explicit object_unref() but I think it's simpler to rely on the QOM child property refcount semantics instead of keeping a duplicate reference. object_property_add_child() increments the refcount. Releasing the child property decrements the refcount again. Now, in the context of the virtio-blk-pci parent object and its VirtIOBlock child: When the parent object is finalized and its properties are released, the ref to the child will automatically be decremented. This is exactly what we need. Stefan