[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/18] qmp: add qom-list command
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH v2 10/18] qmp: add qom-list command |
Date: |
Fri, 2 Dec 2011 14:20:48 -0600 |
This can be used to list properties in the device model.
Signed-off-by: Anthony Liguori <address@hidden>
---
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 cb1ba77..276b7c3 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -887,3 +887,51 @@
# Notes: Do not use this command.
##
{ 'command': 'cpu', 'data': {'index': '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<subtype>' where subtype is the
+# legacy qdev typename. These types are always treated as strings.
+#
+# 3) A child type in the form 'child<subtype>' where subtype is a qdev
+# device type name. Child properties create the composition tree.
+#
+# 4) A link type in the form 'link<subtype>' 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 97975a5..d6ff466 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2001,3 +2001,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 511dd62..06ae569 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)
{
@@ -117,3 +118,30 @@ SpiceInfo *qmp_query_spice(Error **errp)
return NULL;
};
#endif
+
+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
- [Qemu-devel] [PATCH v2 01/18] qom: add a reference count to qdev objects, (continued)
- [Qemu-devel] [PATCH v2 01/18] qom: add a reference count to qdev objects, Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 02/18] qom: add new dynamic property infrastructure based on Visitors (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 03/18] qom: register legacy properties as new style properties (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 05/18] qdev: provide an interface to return canonical path from root (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 07/18] qom: add child properties (composition) (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 04/18] qom: introduce root device, Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 06/18] qdev: provide a path resolution (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 08/18] qom: add link properties (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 10/18] qmp: add qom-list command,
Anthony Liguori <=
- [Qemu-devel] [PATCH v2 13/18] dev: add an anonymous peripheral container, Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 12/18] qdev: add explicitly named devices to the root complex, Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 09/18] qapi: allow a 'gen' key to suppress code generation, Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 14/18] rtc: make piix3 set the rtc as a child (v2), Anthony Liguori, 2011/12/02
- [Qemu-devel] [PATCH v2 16/18] qom: optimize qdev_get_canonical_path using a parent link, Anthony Liguori, 2011/12/02