[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/9] qbus: remove glib_allocated/qom_allocated a
From: |
Anthony Liguori |
Subject: |
Re: [Qemu-devel] [PATCH 3/9] qbus: remove glib_allocated/qom_allocated and use release hook to free memory |
Date: |
Mon, 27 Aug 2012 09:22:13 -0500 |
User-agent: |
Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) |
Andreas Färber <address@hidden> writes:
> Am 26.08.2012 17:51, schrieb Anthony Liguori:
>> Signed-off-by: Anthony Liguori <address@hidden>
>
> That's a really nice solution for cleaning this up, thanks!
>
> Acked-by: Andreas Färber <address@hidden>
>
> However one conceptional detail...
>
>> ---
>> hw/pci.c | 7 ++++++-
>> hw/qdev.c | 15 ---------------
>> hw/qdev.h | 7 -------
>> hw/sysbus.c | 7 ++++++-
>> 4 files changed, 12 insertions(+), 24 deletions(-)
> [...]
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index b5a52ac..6b61daa 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
> [...]
>> @@ -468,18 +466,6 @@ BusState *qbus_create(const char *typename, DeviceState
>> *parent, const char *nam
>> return bus;
>> }
>>
>> -void qbus_free(BusState *bus)
>> -{
>> - if (bus->qom_allocated) {
>> - object_delete(OBJECT(bus));
>> - } else {
>> - object_finalize(OBJECT(bus));
>> - if (bus->glib_allocated) {
>> - g_free(bus);
>> - }
>> - }
>> -}
>> -
>> static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
>> {
>> BusClass *bc = BUS_GET_CLASS(bus);
>> @@ -698,7 +684,6 @@ static void device_finalize(Object *obj)
>> if (dev->state == DEV_STATE_INITIALIZED) {
>> while (dev->num_child_bus) {
>> bus = QLIST_FIRST(&dev->child_bus);
>> - qbus_free(bus);
>> }
>> if (qdev_get_vmsd(dev)) {
>> vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
>
> I wonder how this is gonna work: The device used to be in charge of
> tearing down its bus children ... now it neither deletes nor finalizes
> nor unrefs? Is the while loop even still needed?
>
> Wouldn't the busses still have the device as parent, referencing it,
> blocking device_finalize?
This has never been right.. Just because a controller goes away, it
doesn't mean that the devices ought to go away too.
There are different types of "remove" so let's consider each.
1) Guest visible eject: if a controller is ejected, then the guest will
obviously see everything behind it get removed too. This is an
emulation detail, not a QOM thing.
2) Final deletion: this only happens when all references go away. If
you eject a controller but there are still children that reference
it, the controller won't go away. You actually need to delete each
individual disk (or whatever is behind it) in order to break the
reference counting.
The eject notifier could walk the full bus and attempt to break the
connections but honestly, I'd much prefer that we deprecate the current
device_del interface and just do everything through QOM properties.
That would mean manually deleting all of the devices behind the bus if
that's really what you wanted to do.
Regards,
Anthony Liguori
>
> Regards,
> Andreas
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- [Qemu-devel] [PATCH 7/9] qdev: add notifier for when the device loses its parent bus (eject), (continued)
- [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