qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
Date: Fri, 03 Feb 2012 21:03:36 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 02/03/2012 06:27 PM, Paolo Bonzini wrote:
On 02/03/2012 03:27 PM, Anthony Liguori wrote:
On 02/02/2012 10:45 AM, Paolo Bonzini wrote:
The reference that is returned by qdev_device_add is never given
back, so that device_del does not cause the refcount to go to zero
(and thus does nothing).

Signed-off-by: Paolo Bonzini<address@hidden>

This isn't needed in qom-upstream.14. Here's why:

object_init does not increase the reference count

object_property_add_child increases the reference count
object_new increases the reference count

object_delete decrements the reference count
object_property_del_child decreases the reference count

object_delete calls object_property_del_child(obj->parent, obj)

qdev_device_add calls object_new and object_property_add_child
-> ref == 2

qdev_device_del calls object_delete
-> ref -= 2

In qom-upstream.13, object_delete wasn't calling
object_property_del_child which is why you saw the behavior you did.
This problem would still exist with a composed device so dropping the
reference here isn't enough.

I trust you for now. :)

It really seems like my patch is obviously correct so, if it's not needed
anymore there may be another bug elsewhere that masks it.

There's no object_ref() in qdev_device_add(). The 2 references come from adding a child link to /peripheral and via object_new().

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...

Regards,

Anthony Liguori


Paolo






reply via email to

[Prev in Thread] Current Thread [Next in Thread]