qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a link property
Date: Mon, 27 Aug 2012 08:12:37 -0500
User-agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

liu ping fan <address@hidden> writes:

> On Sun, Aug 26, 2012 at 11:51 PM, Anthony Liguori <address@hidden> wrote:
>> Also make setting the link to NULL break the bus link
>>
>> Signed-off-by: Anthony Liguori <address@hidden>
>> ---
>>  hw/qdev.c |   48 ++++++++++++++++++++++++++++++++++++++++++------
>>  1 files changed, 42 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index 86e1337..525a0cb 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
>> @@ -100,8 +100,7 @@ static void bus_add_child(BusState *bus, DeviceState 
>> *child)
>>
>>  void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
>>  {
>> -    dev->parent_bus = bus;
>> -    bus_add_child(bus, dev);
>> +    object_property_set_link(OBJECT(dev), OBJECT(bus), "parent_bus", NULL);
>>  }
>>
>>  /* Create a new device.  This only initializes the device state structure
>> @@ -241,8 +240,8 @@ void qbus_reset_all_fn(void *opaque)
>>  /* can be used as ->unplug() callback for the simple cases */
>>  int qdev_simple_unplug_cb(DeviceState *dev)
>>  {
>> -    /* just zap it */
>> -    qdev_free(dev);
>> +    /* Unplug from parent bus via a forced eject */
>> +    qdev_set_parent_bus(dev, NULL);
>
> I think it is more reliable to remove the reference property(child,
> link) before object_finialize().  So when uplug-finish, we delete all
> the refers:  bus->child, bus<-child by _del_property not using
> _set_property.

object_finalize is called when ref=0.  You cannot remove refs in
finalize because by definition, ref=0.

Regards,

Anthony Liguori




reply via email to

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