[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 42/48] qmp: introduce device-list-properties command
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 42/48] qmp: introduce device-list-properties command |
Date: |
Mon, 13 Aug 2012 16:49:03 -0300 |
From: Anthony Liguori <address@hidden>
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 <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
qapi-schema.json | 28 ++++++++++++++++++++++++++++
qmp-commands.hx | 7 +++++++
qmp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+)
diff --git a/qapi-schema.json b/qapi-schema.json
index ec8d919..927fdea 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1725,6 +1725,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' ] }
+
+##
# @migrate
#
# Migrates the current running guest to another Virtual Machine.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e07c7b0..e9e0410 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2217,3 +2217,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;
+}
--
1.7.11.2.249.g31c7954.dirty
- [Qemu-devel] [PATCH 19/48] qapi: qapi-types.h: don't include qapi/qapi-types-core.h, (continued)
- [Qemu-devel] [PATCH 19/48] qapi: qapi-types.h: don't include qapi/qapi-types-core.h, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 18/48] hmp: hmp.h: include qdict.h, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 22/48] qapi-schema: add ErrorClass enum, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 28/48] error: drop unused functions, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 33/48] qerror: drop qerror_table and qerror_format(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 34/48] error, qerror: drop QDict member, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 35/48] docs: writing-qmp-commands.txt: update error section, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 36/48] scripts: qapi-commands.py: qmp-commands.h: include qdict.h, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 38/48] qmp: emit the WAKEUP event when the guest is put to run, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 37/48] qmp: don't emit the RESET event on wakeup from S3, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 42/48] qmp: introduce device-list-properties command,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 43/48] qapi: mark QOM commands stable, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 26/48] error: add error_get_class(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 29/48] qmp: switch to the new error format on the wire, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 21/48] qapi: don't convert enum strings to lowercase, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 25/48] qerror: add proper ErrorClass value for QERR_ macros, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 48/48] target-ppc: add implementation of query-cpu-definitions (v2), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 24/48] error, qerror: add ErrorClass argument to error functions, Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 47/48] target-i386: add implementation of query-cpu-definitions (v2), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 31/48] error: drop error_get_qobject()/error_set_qobject(), Luiz Capitulino, 2012/08/13
- [Qemu-devel] [PATCH 27/48] hmp: hmp_change(): use error_get_class(), Luiz Capitulino, 2012/08/13