@@ -65,6 +65,16 @@
'*error': 'str' } }
##
+# @ObjectPropertiesValues:
+#
+# @properties: a list of properties.
+#
+# Since 10.0
+##
+{ 'struct': 'ObjectPropertiesValues',
+ 'data': { 'properties': [ 'ObjectPropertyValue' ] }}
+
+##
# @ObjectNode:
#
# @name: the name of the node
@@ -161,6 +171,30 @@
'allow-preconfig': true }
##
+# @qom-list-getv:
+#
+# This command returns a list of properties and their values for
+# each object path in the input list.
+#
+# @paths: The absolute or partial path for each object, as described
+# in @qom-get
+#
+# Errors:
+# - If any path is not valid or is ambiguous, returns an error.
+# - If a property cannot be read, returns an error message in the
+# corresponding @ObjectPropertyValue.
+#
+# Returns: A list of @ObjectPropertiesValues. Each element contains
+# the properties of the corresponding element in @paths.
+#
+# Since 10.0
+##
+{ 'command': 'qom-list-getv',
+ 'data': { 'paths': [ 'str' ] },
+ 'returns': [ 'ObjectPropertiesValues' ],
+ 'allow-preconfig': true }
+
+##
# @qom-tree-get:
#
# This command returns a tree of objects and their properties,
@@ -87,6 +87,46 @@ static void qom_list_add_property_value(Object *obj, ObjectProperty *prop,
}
}
+static ObjectPropertyValueList *qom_get_property_value_list(const char *path,
+ Error **errp)
+{
+ Object *obj;
+ ObjectProperty *prop;
+ ObjectPropertyIterator iter;
+ ObjectPropertyValueList *props = NULL;
+
+ obj = qom_resolve_path(path, errp);
+ if (obj == NULL) {
+ return NULL;
+ }
+
+ object_property_iter_init(&iter, obj);
+ while ((prop = object_property_iter_next(&iter))) {
+ qom_list_add_property_value(obj, prop, &props);
+ }
+
+ return props;
+}
+
+ObjectPropertiesValuesList *qmp_qom_list_getv(strList *paths, Error **errp)
+{
+ ObjectPropertiesValuesList *head = NULL, **tail = &head;
+
+ for ( ; paths ; paths = paths->next) {
+ ObjectPropertiesValues *item = g_new0(ObjectPropertiesValues, 1);
+
+ QAPI_LIST_APPEND(tail, item);
+
+ item->properties = qom_get_property_value_list(paths->value, errp);
+ if (!item->properties) {
+ qapi_free_ObjectPropertiesValuesList(head);
+ return NULL;
+ }
+ }
+
+ return head;
+}
+
static ObjectNode *qom_tree_get(const char *path, Error **errp)
{
Object *obj;
Define the qom-list-getv command, which fetches all the properties and values for a list of paths. This is faster than qom-tree-get when fetching a subset of the QOM tree. See qom.json for details. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- qapi/qom.json | 34 ++++++++++++++++++++++++++++++++++ qom/qom-qmp-cmds.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+)