All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Steve Sistare <steven.sistare@oracle.com>
Cc: qemu-devel@nongnu.org,  John Snow <jsnow@redhat.com>,
	 Cleber Rosa <crosa@redhat.com>,  Eric Blake <eblake@redhat.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	 "Daniel P. Berrange" <berrange@redhat.com>,
	Eduardo Habkost <eduardo@habkost.net>,
	 Fabiano Rosas <farosas@suse.de>,
	Laurent Vivier <lvivier@redhat.com>,
	Peter Krempa <pkrempa@redhat.com>,
	devel@lists.libvirt.org
Subject: Re: [PATCH V2 4/5] qom: qom-list-getv
Date: Fri, 04 Jul 2025 14:22:46 +0200	[thread overview]
Message-ID: <874ivsno15.fsf@pond.sub.org> (raw)
In-Reply-To: <1747057635-124298-5-git-send-email-steven.sistare@oracle.com> (Steve Sistare's message of "Mon, 12 May 2025 06:47:14 -0700")

Steve Sistare <steven.sistare@oracle.com> writes:

> 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(+)
>
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 94662ad..dc710d6 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -62,6 +62,16 @@
>              '*value': 'any' } }
>  
>  ##
> +# @ObjectPropertiesValues:
> +#
> +# @properties: a list of properties.
> +#
> +# Since 10.1
> +##
> +{ 'struct': 'ObjectPropertiesValues',
> +  'data': { 'properties': [ 'ObjectPropertyValue' ] }}
> +
> +##
>  # @ObjectNode:
>  #
>  # @name: the name of the node
> @@ -158,6 +168,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.

Imperative mood, please: "Return a list of ..."

> +#
> +# @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, the value field is omitted in
> +#       the corresponding @ObjectPropertyValue.

My comment on qom-tree-get's Errors: section applies.

> +#
> +# Returns: A list of @ObjectPropertiesValues.  Each element contains
> +#     the properties of the corresponding element in @paths.

Again, ObjectPropertiesValues is an unfortunate name.

> +#
> +# Since 10.1
> +##
> +{ '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,

I find this command *much* simpler than qom-tree-get.

qom-list-getv treats all properties the same.  References, whether they
are children and links, are the same: a QOM path.

qom-tree-get separates properties into children and non-children.
Children become nested ObjectNodes, links remain QOM paths.

> diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
> index b876681..1f05956 100644
> --- a/qom/qom-qmp-cmds.c
> +++ b/qom/qom-qmp-cmds.c
> @@ -90,6 +90,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) {

I'd prefer a separate variable:

       for (tail = paths; tail; tail = tail->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;

The implementation is simpler than qom-tree's, too.



  reply	other threads:[~2025-07-04 12:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 13:47 [PATCH V2 0/5] fast qom tree get Steve Sistare
2025-05-12 13:47 ` [PATCH V2 1/5] qom: qom-tree-get Steve Sistare
2025-07-04 12:22   ` Markus Armbruster
2025-07-07 14:44     ` Steven Sistare
2025-07-08  5:06       ` Markus Armbruster
2025-07-08  6:53         ` Markus Armbruster
2025-07-08  7:14   ` Philippe Mathieu-Daudé
2025-07-08 11:50     ` Steven Sistare
2025-07-08 15:17       ` Philippe Mathieu-Daudé
2025-05-12 13:47 ` [PATCH V2 2/5] python: use qom-tree-get Steve Sistare
2025-05-12 13:47 ` [PATCH V2 3/5] tests/qtest/qom-test: unit test for qom-tree-get Steve Sistare
2025-07-08  7:15   ` Philippe Mathieu-Daudé
2025-05-12 13:47 ` [PATCH V2 4/5] qom: qom-list-getv Steve Sistare
2025-07-04 12:22   ` Markus Armbruster [this message]
2025-07-07 14:40     ` Steven Sistare
2025-07-08  4:41       ` Markus Armbruster
2025-05-12 13:47 ` [PATCH V2 5/5] tests/qtest/qom-test: unit test for qom-list-getv Steve Sistare
2025-05-19 21:19 ` [PATCH V2 0/5] fast qom tree get Fabiano Rosas
2025-07-04 12:26 ` Markus Armbruster
2025-07-07 14:39   ` Steven Sistare
2025-07-04 12:33 ` Markus Armbruster
2025-07-07 14:39   ` Steven Sistare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874ivsno15.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=crosa@redhat.com \
    --cc=devel@lists.libvirt.org \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=steven.sistare@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.