From: Paolo Bonzini <pbonzini@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
qemu-devel@nongnu.org, Liu Ping Fan <qemulist@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects
Date: Fri, 23 Nov 2012 18:10:07 +0100 [thread overview]
Message-ID: <50AFADEF.6000905@redhat.com> (raw)
In-Reply-To: <50AFAC11.1050500@suse.de>
Il 23/11/2012 18:02, Andreas Färber ha scritto:
>> Store in the object the freeing function that will be used at deletion
>> > time. This makes it possible to use object_delete on statically-allocated
>> > (embedded) objects. Dually, it makes it possible to use object_unparent
>> > and object_unref without leaking memory, when the lifetime of object
>> > might extend until after the call to object_delete.
>> >
>> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> The code is
>
> Reviewed-by: Andreas Färber <afaerber@suse.de>
>
> however I do not agree with the goal in the subject. I thought this was
> to match C++ in actually deallocating the memory.
At the "real" end of the series object_delete disappears completely. I
posted only the initial part because the rest is not appropriate for
1.3, you can see it at https://github.com/bonzini/qemu/commits/qdev-free.
You just have ref/unref to keep an object alive, and unparent to remove it.
qbus_free and qdev_free become simply synonyms for object_unparent.
After the unparent, the refcount is magically zero for the bus/device
and everything below it in the qtree, and they disappear.
Paolo
next prev parent reply other threads:[~2012-11-23 17:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-23 8:47 [Qemu-devel] [PATCH 1.3 0/5] QOM/qdev lifetime fixes Paolo Bonzini
2012-11-23 8:47 ` [Qemu-devel] [PATCH 1.3 1/5] qom: fix refcount of non-heap-allocated objects Paolo Bonzini
2012-11-23 16:49 ` Andreas Färber
2012-11-26 15:49 ` Anthony Liguori
2012-11-26 16:08 ` Paolo Bonzini
2012-11-23 8:47 ` [Qemu-devel] [PATCH 1.3 2/5] qdev: move bus removal to object_unparent Paolo Bonzini
2012-11-23 16:52 ` Andreas Färber
2012-11-27 1:02 ` Andreas Färber
2012-11-23 8:47 ` [Qemu-devel] [PATCH 1.3 3/5] qom: make object_delete usable for statically-allocated objects Paolo Bonzini
2012-11-23 17:02 ` Andreas Färber
2012-11-23 17:10 ` Paolo Bonzini [this message]
2012-11-23 8:47 ` [Qemu-devel] [PATCH 1.3 4/5] qdev: simplify (de)allocation of buses Paolo Bonzini
2012-11-23 17:07 ` Andreas Färber
2012-11-23 17:16 ` Paolo Bonzini
2012-11-23 8:47 ` [Qemu-devel] [PATCH 1.3 5/5] qom: make object_finalize static Paolo Bonzini
2012-11-23 17:12 ` Andreas Färber
2012-11-23 17:32 ` Paolo Bonzini
2012-11-26 21:47 ` [Qemu-devel] [PATCH 1.3 0/5] QOM/qdev lifetime fixes Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50AFADEF.6000905@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemulist@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).