[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/22] qom: add new command to search for types
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 12/22] qom: add new command to search for types |
Date: |
Wed, 1 Feb 2012 13:50:53 -0600 |
This adds a command that allows searching for types that implement a property.
This allows you to do things like search for all available PCIDevices. In the
future, we'll also have a standard interface for things with a BlockDriverState
property that a PCIDevice could implement.
This will enable search queries like, "any type that implements the BlockDevice
interface" which would allow management tools to present available block devices
without having to hard code device names. Since an object can implement
multiple interfaces, one device could act both as a BlockDevice and a
NetworkDevice.
Signed-off-by: Anthony Liguori <address@hidden>
---
qapi-schema.json | 33 +++++++++++++++++++++++++++++++++
qerror.c | 2 +-
qmp-commands.hx | 5 +++++
qmp.c | 27 +++++++++++++++++++++++++++
4 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 80debe6..56a4123 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1549,3 +1549,36 @@
# Since: 1.1
##
{ 'command': 'block_job_cancel', 'data': { 'device': 'str' } }
+
+##
+# @ObjectTypeInfo:
+#
+# This structure describes a search result from @qom-list-types
+#
+# @name: the type name found in the search
+#
+# Since: 1.1
+#
+# Notes: This command is experimental and may change syntax in future releases.
+##
+{ 'type': 'ObjectTypeInfo',
+ 'data': { 'name': 'str' } }
+
+##
+# @qom-list-types:
+#
+# This command will return a list of types given search parameters
+#
+# @implements: if specified, only return types that implement this type name
+#
+# @abstract: if true, include abstract types in the results
+#
+# Returns: a list of @ObjectTypeInfo or an empty list if no results are found
+#
+# Since: 1.1
+#
+# Notes: This command is experimental and may change syntax in future releases.
+##
+{ 'command': 'qom-list-types',
+ 'data': { '*implements': 'str', '*abstract': 'bool' },
+ 'returns': [ 'ObjectTypeInfo' ] }
diff --git a/qerror.c b/qerror.c
index 637eca7..3d179c8 100644
--- a/qerror.c
+++ b/qerror.c
@@ -161,7 +161,7 @@ static const QErrorStringTable qerror_table[] = {
},
{
.error_fmt = QERR_INVALID_PARAMETER_TYPE,
- .desc = "Invalid parameter type, expected: %(expected)",
+ .desc = "Invalid parameter type for '%(name)', expected:
%(expected)",
},
{
.error_fmt = QERR_INVALID_PARAMETER_VALUE,
diff --git a/qmp-commands.hx b/qmp-commands.hx
index bd6b641..b5e2ab8 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2042,3 +2042,8 @@ EQMP
.args_type = "password:s",
.mhandler.cmd_new = qmp_marshal_input_change_vnc_password,
},
+ {
+ .name = "qom-list-types",
+ .args_type = "implements:s?,abstract:b?",
+ .mhandler.cmd_new = qmp_marshal_input_qom_list_types,
+ },
diff --git a/qmp.c b/qmp.c
index 1222b6c..75049ed 100644
--- a/qmp.c
+++ b/qmp.c
@@ -395,3 +395,30 @@ void qmp_change(const char *device, const char *target,
qmp_change_blockdev(device, target, has_arg, arg, err);
}
}
+
+static void qom_list_types_tramp(ObjectClass *klass, void *data)
+{
+ ObjectTypeInfoList *e, **pret = data;
+ ObjectTypeInfo *info;
+
+ info = g_malloc0(sizeof(*info));
+ info->name = g_strdup(object_class_get_name(klass));
+
+ e = g_malloc0(sizeof(*e));
+ e->value = info;
+ e->next = *pret;
+ *pret = e;
+}
+
+ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
+ const char *implements,
+ bool has_abstract,
+ bool abstract,
+ Error **errp)
+{
+ ObjectTypeInfoList *ret = NULL;
+
+ object_class_foreach(qom_list_types_tramp, implements, abstract, &ret);
+
+ return ret;
+}
--
1.7.4.1
- [Qemu-devel] [PATCH 02/22] usb: separate out legacy usb registration from type registration, (continued)
- [Qemu-devel] [PATCH 02/22] usb: separate out legacy usb registration from type registration, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 03/22] qdev: make DeviceInfo private, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 04/22] qdev: remove info from class, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 06/22] qdev: refactor device creation to allow bus_info to be set only in class, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 05/22] qdev: allow classes to overload qdev functions, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 08/22] qdev: kill off DeviceInfo list, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 10/22] qdev: kill off DeviceInfo, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 11/22] qdev: remove baked in notion of aliases (v2), Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 16/22] qdev: nuke qdev_init_chardev(), Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 15/22] qdev: split out UI portions into a new function, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 12/22] qom: add new command to search for types,
Anthony Liguori <=
- [Qemu-devel] [PATCH 17/22] qom: move properties from qdev to object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 20/22] info qdm: do not require a parent_bus to be set, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 21/22] object: sure up reference counting, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 09/22] qdev: register all types natively through QEMU Object Model, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 22/22] container: make a decendent of Object, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 19/22] qdev: implement cleanup logic in finalize, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 07/22] qom: allow object_class_foreach to take additional parameters to refine search, Anthony Liguori, 2012/02/01
- [Qemu-devel] [PATCH 14/22] qdev: refactor away qdev_create_from_info, Anthony Liguori, 2012/02/01