Received: from eggs.gnu.org ([140.186.70.92]:45412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCW8-0008By-LO for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:30:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaCW7-0002Lg-5t for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:30:32 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:49806 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCW6-0002LN-F8 for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:30:31 -0500 From: Anthony Liguori Date: Mon, 12 Dec 2011 14:29:34 -0600 Message-Id: <1323721784-704-11-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1323721784-704-1-git-send-email-aliguori@us.ibm.com> References: <1323721784-704-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH v3 10/20] qmp: add qom-list command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino This can be used to list properties in the device model. Signed-off-by: Anthony Liguori --- qapi-schema.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 0 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index f358b49..7c979b2 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1168,3 +1168,51 @@ # Since: 0.14.0 ## { 'command': 'migrate_set_speed', 'data': {'value': 'int'} } + +## +# @DevicePropertyInfo: +# +# @name: the name of the property +# +# @type: the type of the property. This will typically come in one of four +# forms: +# +# 1) A primitive type such as 'u8', 'u16', 'bool', 'str', or 'double'. +# These types are mapped to the appropriate JSON type. +# +# 2) A legacy type in the form 'legacy' where subtype is the +# legacy qdev typename. These types are always treated as strings. +# +# 3) A child type in the form 'child' where subtype is a qdev +# device type name. Child properties create the composition tree. +# +# 4) A link type in the form 'link' where subtype is a qdev +# device type name. Link properties form the device model graph. +# +# Since: 1.1 +# +# Notes: This type is experimental. Its syntax may change in future releases. +## +{ 'type': 'DevicePropertyInfo', + 'data': { 'name': 'str', 'type': 'str' } } + +## +# @qom-list: +# +# This command will list any properties of a device given a path in the device +# model. +# +# @path: the path within the device model. See @qom-get for a description of +# this parameter. +# +# Returns: a list of @DevicePropertyInfo that describe the properties of the +# device. +# +# Since: 1.1 +# +# Notes: This command is experimental. It's syntax may change in future +# releases. +## +{ 'command': 'qom-list', + 'data': { 'path': 'str' }, + 'returns': [ 'DevicePropertyInfo' ] } diff --git a/qmp-commands.hx b/qmp-commands.hx index 002e7e8..c1f0718 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2009,3 +2009,9 @@ EQMP .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_balloon, }, + + { + .name = "qom-list", + .args_type = "path:s", + .mhandler.cmd_new = qmp_marshal_input_qom_list, + }, diff --git a/qmp.c b/qmp.c index d71ceb4..8e9a595 100644 --- a/qmp.c +++ b/qmp.c @@ -16,6 +16,7 @@ #include "qmp-commands.h" #include "kvm.h" #include "arch_init.h" +#include "hw/qdev.h" NameInfo *qmp_query_name(Error **errp) { @@ -154,3 +155,30 @@ void qmp_cont(Error **errp) vm_start(); } + +DevicePropertyInfoList *qmp_qom_list(const char *path, Error **errp) +{ + DeviceState *dev; + bool ambiguous = false; + DevicePropertyInfoList *props = NULL; + DeviceProperty *prop; + + dev = qdev_resolve_path(path, &ambiguous); + if (dev == NULL) { + error_set(errp, QERR_DEVICE_NOT_FOUND, path); + return NULL; + } + + QTAILQ_FOREACH(prop, &dev->properties, node) { + DevicePropertyInfoList *entry = g_malloc0(sizeof(*entry)); + + entry->value = g_malloc0(sizeof(DevicePropertyInfo)); + entry->next = props; + props = entry; + + entry->value->name = g_strdup(prop->name); + entry->value->type = g_strdup(prop->type); + } + + return props; +} -- 1.7.4.1