All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PATCH RFC 1/3] qom: Add "realized" property to Object
Date: Mon, 26 Mar 2012 17:07:13 +0200	[thread overview]
Message-ID: <4F708621.10009@suse.de> (raw)
In-Reply-To: <1332769612-4247-2-git-send-email-afaerber@suse.de>

Am 26.03.2012 15:46, schrieb Andreas Färber:
> The Object::realized property can only be set once and, on setting it,
> invokes the ObjectClass::realize callback.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/object.h |    2 ++
>  qom/object.c          |   31 +++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 0 deletions(-)
[snip]
> diff --git a/qom/object.c b/qom/object.c
> index 9cd9506..ec143ad 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -273,6 +273,34 @@ static void object_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +static void object_get_realized(Object *obj, Visitor *v, void *opaque,
> +                                const char *name, Error **errp)
> +{
> +    visit_type_bool(v, &obj->realized, name, errp);
> +}
> +
> +static void object_set_realized(Object *obj, Visitor *v, void *opaque,
> +                                const char *name, Error **errp)
> +{
> +    bool value;
> +
> +    if (obj->realized) {
> +        error_set(errp, QERR_PERMISSION_DENIED);
> +        return;
> +    }
> +
> +    visit_type_bool(v, &value, name, errp);
> +    if (error_is_set(errp) || !value) {
> +        return;
> +    }
> +
> +    if (obj->class->realize != NULL && obj->class->realize(obj) != 0) {
> +        error_set(errp, QERR_DEVICE_INIT_FAILED, object_get_typename(obj));

Will introduce a QERR_OBJECT_REALIZE_FAILED for v2 based on feedback.

/-F

> +        return;
> +    }
> +    obj->realized = true;
> +}
> +
>  void object_initialize_with_type(void *data, TypeImpl *type)
>  {
>      Object *obj = data;
[snip]

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-03-26 15:07 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 [this message]
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
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=4F708621.10009@suse.de \
    --to=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.