summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qapi-schema.json33
-rw-r--r--qerror.c2
-rw-r--r--qmp-commands.hx5
-rw-r--r--qmp.c27
4 files changed, 66 insertions, 1 deletions
diff --git a/qapi-schema.json b/qapi-schema.json
index 80debe679a..56a4123b5b 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 637eca793c..3d179c87ea 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 bd6b6410ad..b5e2ab8574 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 1222b6c9c4..75049ed884 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;
+}