[Top][All Lists]
[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
- [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 1/9] savevm: don't rely on paths if we can store a DeviceState object, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add nullable so they can be deleted, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 4/9] object: remove object_finalize, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 7/9] qdev: add notifier for when the device loses its parent bus (eject), Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 2/9] object: automatically free objects based on a release function, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a link property, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 9/9] hotplug: refactor hotplug to leverage new QOM functions, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 3/9] qbus: remove glib_allocated/qom_allocated and use release hook to free memory, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 5/9] object: add support for nullable child properties, Anthony Liguori, 2012/08/26
- Re: [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug, liu ping fan, 2012/08/27