From: "Andreas Färber" <afaerber@suse.de>
To: Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 05/10] qdev: push state up to Object
Date: Fri, 25 May 2012 18:58:58 +0200 [thread overview]
Message-ID: <4FBFBA52.8040900@suse.de> (raw)
In-Reply-To: <1337787881-3579-6-git-send-email-pbonzini@redhat.com>
Am 23.05.2012 17:44, schrieb Paolo Bonzini:
> qdev properties use the state member (an embryo of the "realized"
> property) in order to disable setting them after a device has been
> initialized. So, in order to push qdev properties up to Object
> we need to push this bit there too.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[...]
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 5d6dc1f..552169b 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
[...]
> @@ -671,7 +671,6 @@ static void device_initfn(Object *obj)
> }
>
> dev->instance_id_alias = -1;
> - dev->state = DEV_STATE_CREATED;
>
> class = object_get_class(OBJECT(dev));
> do {
[...]
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index cb08cfa..cb11288 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -244,6 +244,11 @@ struct ObjectClass
> const char *(*get_id)(Object *);
> };
>
> +typedef enum ObjectState {
> + OBJECT_STATE_CREATED = 1,
> + OBJECT_STATE_REALIZED,
> +} ObjectState;
> +
> /**
> * Object:
> *
[...]
> diff --git a/qom/object.c b/qom/object.c
> index b19ef94..ed89b16 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1249,9 +1249,15 @@ static char *qdev_get_type(Object *obj, Error **errp)
> return g_strdup(object_get_typename(obj));
> }
>
> +bool object_is_realized(Object *obj)
> +{
> + return obj->state == OBJECT_STATE_REALIZED;
> +}
> +
> static void object_instance_init(Object *obj)
> {
> object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
> + obj->state = OBJECT_STATE_CREATED;
I wonder if we could improve the ordering here? device_initfn happens to
be the only instance_init function for qdev devices in hw/, but that's
different for Object.
What happens here is that TYPE_FOO is going to be initialized. TYPE_FOO
has .parent TYPE_BAR, TYPE_BAR in turn TYPE_OBJECT. So the QOM init
functions first run our object_instance_init(), which sets the state to
CREATED, then runs bar_initfn() and foo_initfn(). If those call any
helpers that check the object state, they would get a wrong impression.
Seeing that we only check for REALIZED or not, do we actually need this
state at all? We could just have OBJECT_STATE_UNREALIZED = 0 for
implicit initialization.
On the other hand the naming is a bit unfortunate, we actually seem to
mean INITIALIZED rather than CREATED, in QOM terms. Having an indicator
whether QOM actually created the object would solve part of the
qdev/qom/glib_allocated issue I ran into with QBus, i.e. a flag
OBJECT_STATE_ALLOCATED to be combined with INITIALIZED/REALIZED could
indicate whether we can/should object_delete() it in qbus_free(),
INITIALIZED would optionally indicate whether all initializers have been
run (move it out of object_instance_init for clearer semantics) and
REALIZED for the second-stage init we are longing to get. ;-)
Andreas
> }
>
> static void object_class_init(ObjectClass *klass, void *class_data)
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-05-25 16:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 15:44 [Qemu-devel] [PATCH 00/10] push static properties to Object, add realized property Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 01/10] qdev: remove PropertyInfo range checking Paolo Bonzini
2012-05-24 17:50 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 02/10] qdev: remove qdev_prop_exists Paolo Bonzini
2012-05-24 21:34 ` Andreas Färber
2012-05-25 7:20 ` Paolo Bonzini
2012-05-25 15:57 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 03/10] qom: push error reporting to object_property_find Paolo Bonzini
2012-05-25 16:05 ` Andreas Färber
2012-05-26 9:58 ` Paolo Bonzini
2012-05-26 22:04 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 04/10] qom: add get_id Paolo Bonzini
2012-05-25 16:33 ` Andreas Färber
2012-05-25 17:39 ` malc
2012-05-23 15:44 ` [Qemu-devel] [PATCH 05/10] qdev: push state up to Object Paolo Bonzini
2012-05-25 16:58 ` Andreas Färber [this message]
2012-05-23 15:44 ` [Qemu-devel] [PATCH 06/10] qdev: generalize properties to Objects Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 07/10] qdev: move bulk of qdev-properties.c to qom/object.c Paolo Bonzini
2012-05-25 13:32 ` Andreas Färber
2012-05-25 13:36 ` Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 08/10] qom: push static properties to Object Paolo Bonzini
2012-06-07 16:36 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 09/10] qom: add realized property Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 10/10] qom: Add QERR_PROPERTY_SET_AFTER_REALIZE 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=4FBFBA52.8040900@suse.de \
--to=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=imammedo@redhat.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 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.