qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Wanpeng Li" <liwp@linux.vnet.ibm.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH RFC 0/3] qom: Generalize qdev init to "realize"
Date: Tue, 27 Mar 2012 13:56:07 -0500	[thread overview]
Message-ID: <4F720D47.2070304@codemonkey.ws> (raw)
In-Reply-To: <4F71EECE.6000307@redhat.com>

On 03/27/2012 11:46 AM, Paolo Bonzini wrote:
> Il 27/03/2012 18:33, Peter Maydell ha scritto:
>>>> Yes, I haven't reviewed this series yet, but my expectation would be that
>>>> realize propagates and that the default implementation of
>>>> DeviceClass::realize() would explicitly *not* propagate and instead just
>>>> call ::init.
>> So who calls realize for non-qdev QOM objects which are children of
>> qdev QOM objects?
>>
>> I really don't like having the object lifecycle methods be different
>> for DeviceClass than for base objects if we can avoid it.
>
> The way I read it was that the "realize" property propagates to the
> children and calls either the "realize" or "reset" method (in the
> appropriate order).

Correct.

We would probably want to have two methods in Object:

/* realize yourself */
void realize(Error **errp);

/* realize your children */
void realize_children(Error **errp);

The actual realize property would call this->realize(errp); then 
this->realize_children(errp) modulo some cleverness to support transversal ordering.

That means usually, you can just implement realize() and rely on the standard 
child realize support.  But you could overload realize_children() if you needed to.

realize_children() would propagate to child<> properties.  All child<> 
properties trace their parentage back to the object_get_root() device.  So you 
can realize() the entire device/object model by setting the top level realize 
property.

>
> DeviceClass::realize() would also do other things done currently by
> qdev_init, such as register vmstate,

Correct.  I think DeviceClass::realize() should call DeviceClass::init() to 
start out with.  Then we can refactor incrementally to move stuff from ::init() 
to ::realize().  Some parts of :init() will get moved to the constructor.

> so there would still be a
> separation between DeviceClass::realize and DeviceClass::init (we do not
> want yet another pass through the whole tree).
>
> qdev_init would be a thin wrapper around object_realize that takes care
> of freeing the object when init fails.

Absolutely.

Regards,

Anthony Liguori

>
> Is this correct?
>
> Paolo

  reply	other threads:[~2012-03-27 18:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 13:46 [Qemu-devel] [PATCH RFC 0/3] qom: Generalize qdev init to "realize" Andreas Färber
2012-03-26 13:46 ` [Qemu-devel] [PATCH RFC 1/3] qom: Add "realized" property to Object Andreas Färber
2012-03-26 15:07   ` Andreas Färber
2012-03-27  9:25   ` Stefan Hajnoczi
2012-03-26 13:46 ` [Qemu-devel] [PATCH RFC 2/3] qom: Introduce object_realize() Andreas Färber
2012-03-26 13:46 ` [Qemu-devel] [PATCH RFC 3/3] qdev: Hook up DeviceClass::init to ObjectClass::realize Andreas Färber
2012-03-26 13:54   ` Andreas Färber
2012-03-27 16:19 ` [Qemu-devel] [PATCH RFC 0/3] qom: Generalize qdev init to "realize" Paolo Bonzini
2012-03-27 16:28   ` Anthony Liguori
2012-03-27 16:33     ` Peter Maydell
2012-03-27 16:46       ` Paolo Bonzini
2012-03-27 18:56         ` Anthony Liguori [this message]
2012-03-27 16:41     ` Paolo Bonzini

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=4F720D47.2070304@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=afaerber@suse.de \
    --cc=liwp@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).