From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCBVz-0004pq-Pm for qemu-devel@nongnu.org; Mon, 26 Mar 2012 11:07:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCBVr-0005P6-2v for qemu-devel@nongnu.org; Mon, 26 Mar 2012 11:07:23 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49365 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCBVq-0005Nh-QV for qemu-devel@nongnu.org; Mon, 26 Mar 2012 11:07:15 -0400 Message-ID: <4F708621.10009@suse.de> Date: Mon, 26 Mar 2012 17:07:13 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1332769612-4247-1-git-send-email-afaerber@suse.de> <1332769612-4247-2-git-send-email-afaerber@suse.de> In-Reply-To: <1332769612-4247-2-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC 1/3] qom: Add "realized" property to Object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Peter Maydell Am 26.03.2012 15:46, schrieb Andreas F=C3=A4rber: > The Object::realized property can only be set once and, on setting it, > invokes the ObjectClass::realize callback. >=20 > Signed-off-by: Andreas F=C3=A4rber > Cc: Anthony Liguori > Cc: Paolo Bonzini > --- > 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, Typ= eImpl *ti) > } > } > =20 > +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 !=3D NULL && obj->class->realize(obj) !=3D= 0) { > + error_set(errp, QERR_DEVICE_INIT_FAILED, object_get_typename(o= bj)); Will introduce a QERR_OBJECT_REALIZE_FAILED for v2 based on feedback. /-F > + return; > + } > + obj->realized =3D true; > +} > + > void object_initialize_with_type(void *data, TypeImpl *type) > { > Object *obj =3D data; [snip] --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg