From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXxS5-0005I7-G9 for qemu-devel@nongnu.org; Fri, 25 May 2012 12:33:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXxS3-0006JD-FY for qemu-devel@nongnu.org; Fri, 25 May 2012 12:33:21 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57274 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXxS3-0006IK-6L for qemu-devel@nongnu.org; Fri, 25 May 2012 12:33:19 -0400 Message-ID: <4FBFB446.7080105@suse.de> Date: Fri, 25 May 2012 18:33:10 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1337787881-3579-1-git-send-email-pbonzini@redhat.com> <1337787881-3579-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1337787881-3579-5-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 04/10] qom: add get_id List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Igor Mammedov , qemu-devel@nongnu.org, Anthony Liguori , Peter Maydell Am 23.05.2012 17:44, schrieb Paolo Bonzini: > Some classes may present objects differently in errors, for example if = they > are not part of the composition tree or if they are not assigned an id = by > the user. Let them do this with a get_id method on Object, and use the > method consistently where a %(device) appears in the error. >=20 > Signed-off-by: Paolo Bonzini This patch looks new, so it's not covered by Anthony's carte blanche to take Paolo's patches into qom-next. Generally I'm fine with it, some formal issues below. > --- > hw/qdev-properties.c | 6 +++--- > hw/qdev.c | 15 ++++++++++++++- > include/qemu/object.h | 11 +++++++++++ > qom/object.c | 26 +++++++++++++++++++++++++- > 4 files changed, 53 insertions(+), 5 deletions(-) > diff --git a/hw/qdev.c b/hw/qdev.c > index e909f3b..5d6dc1f 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c [...] > @@ -714,6 +714,13 @@ static void device_finalize(Object *obj) > } > } > =20 > +static const char *qdev_get_id(Object *obj) > +{ > + DeviceState *dev =3D DEVICE(obj); > + > + return dev->id?:object_get_typename(obj); Spaces around ?: please. > +} > + > static void device_class_base_init(ObjectClass *class, void *data) > { > DeviceClass *klass =3D DEVICE_CLASS(class); [...] > diff --git a/qom/object.c b/qom/object.c > index 68a4c57..b19ef94 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -334,6 +334,24 @@ static void object_property_del_child(Object *obj,= Object *child, Error **errp) > } > } > =20 > +static const char *_object_get_id(Object *obj) malc's alarm bells will be ringing: Use of an identifier starting with underscore. What about object_get_default_id()? > +{ > + ObjectProperty *prop; > + > + QTAILQ_FOREACH(prop, &obj->properties, node) { > + if (strstart(prop->type, "child<", NULL) && prop->opaque =3D=3D= obj) { At one point we were discussing an object_property_is_child() inline helper. I'd really prefer not to spread string comparisons everywhere. I'll submit a patch based on this one: http://lists.gnu.org/archive/html/qemu-devel/2012-02/msg02549.html Andreas > + return prop->name; > + } > + } > + > + return ""; > +} > + > +const char *object_get_id(Object *obj) > +{ > + return obj->class->get_id(obj); > +} > + > void object_unparent(Object *obj) > { > if (obj->parent) { [...] > @@ -1236,6 +1254,11 @@ static void object_instance_init(Object *obj) > object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); > } > =20 > +static void object_class_init(ObjectClass *klass, void *class_data) > +{ > + klass->get_id =3D _object_get_id; > +} > + > static void register_types(void) > { > static TypeInfo interface_info =3D { [snip] --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg