qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] commit da57febfed "qdev: give all devices a canonical p


From: Paolo Bonzini
Subject: Re: [Qemu-devel] commit da57febfed "qdev: give all devices a canonical path" broke usb_del
Date: Wed, 08 Aug 2012 15:02:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

Il 08/08/2012 14:48, Andreas Färber ha scritto:
> Adding object_unparent() to object_delete() looks okay to me, but we
> should not forget about the upcoming i440fx and prep_pci use cases where
> we want to embed children in the parent's struct, so that
> object_delete() will never be called on it. Thus object_unparent() would
> need to remain present in the deinit path, no?

object_property_del_all should take care of it for embedded objects:
- the outermost struct is deleted via object_delete
- it is unparented and unrefed, so refcount goes to 0 and finalize is called
- finalize calls object_property_del_all
- object_finalize_child_property calls unref on the nested object, so
refcount goes to 0 and finalize is called.  Things can then proceed
recursively.

It would be more complicated (and would cause memory leaks) if you got
nested objects that were allocated.  To account for this, I understood
you would need something like the following:

- you add a "void (*release)(void *obj)" member to Object.
- object_new sets the release member to g_free
- object_delete does not call g_free anymore
- object_finalize calls the release member if it is not NULL

Do you have time to implement it?

Paolo



reply via email to

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