|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug |
Date: | Sat, 04 Feb 2012 07:51:13 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 |
On 02/04/2012 04:03 AM, Anthony Liguori wrote:
There's no object_ref() in qdev_device_add(). The 2 references come from adding a child link to /peripheral and via object_new().
Sure, but there's when the object_new() reference becomes unreachable. At this point, if it weren't for /peripheral the device should have disappeared.
object_free() drops a reference (it's called in qdev_device_del()) and in the process of calling object_free(), it also calls object_unparent() which will drop the reference from the parent. I'm not thrilled about the way reference counting is done now. Perhaps we should do a gobject style floating reference...
I'm not sure that's a problem. Rather, the problem is that we are (still) mixing manual memory management and refcounting by making object_delete drop a reference.
Can you remind me of why you have object_unref separate from object_delete? Is it because you must not delete objects that were object_initialize'd rather than object_new'd? Perhaps we can take care of that with a flag elsewhere saying "do not free this object when object_unref drops the last ref" (only finalize it).
Thanks for analyzing the behavior. We don't have to get it right immediately as long as we know what's going on, the transition is not complete anyway.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |