Received: from eggs.gnu.org ([2001:4830:134:3::10]:42701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO5ej-0006mp-D5 for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:35:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO5eg-0003cn-2t for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:35:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO5ef-0003cd-RO for qemu-devel@nongnu.org; Tue, 26 Jan 2016 10:35:42 -0500 Date: Tue, 26 Jan 2016 13:35:38 -0200 From: Eduardo Habkost Message-ID: <20160126153538.GN3869@thinpad.lan.raisama.net> References: <1453710287-12706-1-git-send-email-valentin.rakush@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1453710287-12706-1-git-send-email-valentin.rakush@gmail.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5] qom, qmp, hmp, qapi: create qom-type-prop-list for class properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Valentin Rakush Cc: armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, asmetanin@virtuozzo.com, den@openvz.org, afaerber@suse.de On Mon, Jan 25, 2016 at 11:24:47AM +0300, Valentin Rakush wrote: > This patch adds support for qom-type-prop-list command to list object > class properties. A later patch will use this functionality to > implement x86_64-cpu properties. >=20 > Signed-off-by: Valentin Rakush > Cc: Luiz Capitulino > Cc: Eric Blake > Cc: Markus Armbruster > Cc: Andreas F=E4rber > Cc: Daniel P. Berrange > Cc: Eduardo Habkost > --- [...] > diff --git a/qmp.c b/qmp.c > index 53affe2..baf25c0 100644 > --- a/qmp.c > +++ b/qmp.c > @@ -460,6 +460,37 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_im= plements, > return ret; > } > =20 > +ObjectPropertyInfoList *qmp_qom_type_prop_list(const char *typename, E= rror **errp) > +{ > + ObjectClass *klass; > + ObjectPropertyInfoList *props =3D NULL; > + ObjectProperty *prop; > + ObjectPropertyIterator iter; > + > + klass =3D object_class_by_name(typename); > + if (!klass) { > + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, > + "Object class '%s' not found", typename); > + return NULL; > + } > + > + object_class_property_iter_init(&iter, klass); > + while ((prop =3D object_property_iter_next(&iter))) { > + ObjectPropertyInfoList *entry =3D g_new0(ObjectPropertyInfoLis= t, 1); > + > + if (entry) { > + entry->value =3D g_new0(ObjectPropertyInfo, 1); > + entry->next =3D props; > + props =3D entry; > + > + entry->value->name =3D g_strdup(prop->name); > + entry->value->type =3D g_strdup(prop->type); > + } > + } > + > + return props; > +} > + We already have "-device ,help", and it uses a completely different mechanism for listing properties. There's no reason for having two arbitrarily different APIs for listing properties returning different results. If qmp_device_list_properties() is not enough for you, please clarify why, so we can consider improving it. > /* Return a DevicePropertyInfo for a qdev property. > * > * If a qdev property with the given name does not exist, use the give= n default > diff --git a/qom/object.c b/qom/object.c > index 5ff97ab..cabd91d 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -994,6 +994,13 @@ ObjectProperty *object_property_find(Object *obj, = const char *name, > return NULL; > } > =20 > +void object_class_property_iter_init(ObjectPropertyIterator *iter, > + ObjectClass *klass) > +{ > + g_hash_table_iter_init(&iter->iter, klass->properties); > + iter->nextclass =3D object_class_get_parent(klass); > +} > + > void object_property_iter_init(ObjectPropertyIterator *iter, > Object *obj) > { > --=20 > 1.8.3.1 >=20 --=20 Eduardo