From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzqO2-0002RP-HI for qemu-devel@nongnu.org; Fri, 10 Aug 2012 10:40:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzqNw-0001wv-Gj for qemu-devel@nongnu.org; Fri, 10 Aug 2012 10:40:26 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:58403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzqNw-0001wp-CC for qemu-devel@nongnu.org; Fri, 10 Aug 2012 10:40:20 -0400 Received: from /spool/local by e4.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Aug 2012 10:40:19 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id DF091C90042 for ; Fri, 10 Aug 2012 10:40:16 -0400 (EDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7AEeFhW115416 for ; Fri, 10 Aug 2012 10:40:15 -0400 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7AEeDdt003866 for ; Fri, 10 Aug 2012 08:40:14 -0600 From: Anthony Liguori In-Reply-To: <20120727130525.004c8a7e@doriath.home> References: <1343396239-19272-1-git-send-email-aliguori@us.ibm.com> <1343396239-19272-2-git-send-email-aliguori@us.ibm.com> <20120727130525.004c8a7e@doriath.home> Date: Fri, 10 Aug 2012 09:40:06 -0500 Message-ID: <87obmi6cah.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 1/7] qmp: introduce device-list-properties command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Peter Maydell , libvir-list@redhat.com, qemu-devel@nongnu.org, Markus Armbruster , Alexander Graf , Eric Blake Luiz Capitulino writes: > On Fri, 27 Jul 2012 08:37:13 -0500 > Anthony Liguori wrote: > >> This can be used in conjunction with qom-list-types to determine the supported >> set of devices and their parameters. >> >> Signed-off-by: Anthony Liguori >> --- >> qapi-schema.json | 28 ++++++++++++++++++++++++++++ >> qmp-commands.hx | 7 +++++++ >> qmp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 85 insertions(+), 0 deletions(-) >> >> diff --git a/qapi-schema.json b/qapi-schema.json >> index bc55ed2..015a84a 100644 >> --- a/qapi-schema.json >> +++ b/qapi-schema.json >> @@ -1727,6 +1727,34 @@ >> 'returns': [ 'ObjectTypeInfo' ] } >> >> ## >> +# @DevicePropertyInfo: >> +# >> +# Information about device properties. >> +# >> +# @name: the name of the property >> +# @type: the typename of the property >> +# >> +# Since: 1.2 >> +## >> +{ 'type': 'DevicePropertyInfo', >> + 'data': { 'name': 'str', 'type': 'str' } } >> + >> +## >> +# @device-list-properties: >> +# >> +# List properties associated with a device. >> +# >> +# @typename: the type name of a device >> +# >> +# Returns: a list of DevicePropertyInfo describing a devices properties >> +# >> +# Since: 1.2 >> +## >> +{ 'command': 'device-list-properties', >> + 'data': { 'typename': 'str'}, >> + 'returns': [ 'DevicePropertyInfo' ] } > > I find it a bit weird that the argument is called typename but everything else > refers to that same argument as a device. > > Maybe we should rename this to device-type-list-properties, DeviceTypePropertyInfo > and typename to name. I see where you're coming from but I think I'd prefer to leave it as-is. 'DeviceType' isn't really a concept in QEMU. Regards, Anthony Liguori > > But that's minor, I won't oppose to it as it's. > >> + >> +## >> # @migrate >> # >> # Migrates the current running guest to another Virtual Machine. >> diff --git a/qmp-commands.hx b/qmp-commands.hx >> index e3cf3c5..5c55528 100644 >> --- a/qmp-commands.hx >> +++ b/qmp-commands.hx >> @@ -2215,3 +2215,10 @@ EQMP >> .args_type = "implements:s?,abstract:b?", >> .mhandler.cmd_new = qmp_marshal_input_qom_list_types, >> }, >> + >> + { >> + .name = "device-list-properties", >> + .args_type = "typename:s", >> + .mhandler.cmd_new = qmp_marshal_input_device_list_properties, >> + }, >> + >> diff --git a/qmp.c b/qmp.c >> index fee9fb2..254a32f 100644 >> --- a/qmp.c >> +++ b/qmp.c >> @@ -417,3 +417,53 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, >> >> return ret; >> } >> + >> +DevicePropertyInfoList *qmp_device_list_properties(const char *typename, >> + Error **errp) >> +{ >> + ObjectClass *klass; >> + Property *prop; >> + DevicePropertyInfoList *prop_list = NULL; >> + >> + klass = object_class_by_name(typename); >> + if (klass == NULL) { >> + error_set(errp, QERR_DEVICE_NOT_FOUND, typename); >> + return NULL; >> + } >> + >> + klass = object_class_dynamic_cast(klass, TYPE_DEVICE); >> + if (klass == NULL) { >> + error_set(errp, QERR_INVALID_PARAMETER_VALUE, >> + "name", TYPE_DEVICE); >> + return NULL; >> + } >> + >> + do { >> + for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) { >> + DevicePropertyInfoList *entry; >> + DevicePropertyInfo *info; >> + >> + /* >> + * TODO Properties without a parser are just for dirty hacks. >> + * qdev_prop_ptr is the only such PropertyInfo. It's marked >> + * for removal. This conditional should be removed along with >> + * it. >> + */ >> + if (!prop->info->set) { >> + continue; /* no way to set it, don't show */ >> + } >> + >> + info = g_malloc0(sizeof(*info)); >> + info->name = g_strdup(prop->name); >> + info->type = g_strdup(prop->info->legacy_name ?: prop->info->name); >> + >> + entry = g_malloc0(sizeof(*entry)); >> + entry->value = info; >> + entry->next = prop_list; >> + prop_list = entry; >> + } >> + klass = object_class_get_parent(klass); >> + } while (klass != object_class_by_name(TYPE_DEVICE)); >> + >> + return prop_list; >> +}