qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, berrange@redhat.com, ehabkost@redhat.com
Subject: Re: [PATCH not-for-merge 2/5] qom: Make "info qom-tree" show children sorted
Date: Mon, 18 May 2020 16:04:19 -0500	[thread overview]
Message-ID: <c6eae4be-7d00-bc47-f5a0-4a5977136ac0@redhat.com> (raw)
In-Reply-To: <20200518051945.8621-3-armbru@redhat.com>

On 5/18/20 12:19 AM, Markus Armbruster wrote:
> "info qom-tree" prints children in unstable order.  This is a pain
> when diffing output for different versions to find change.  Print it
> sorted.

Yes, this does seem reasonable to include even without the rest of the 
series.

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   qom/qom-hmp-cmds.c | 40 +++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> index 4a61ee1b8c..cf0af8f6b5 100644
> --- a/qom/qom-hmp-cmds.c
> +++ b/qom/qom-hmp-cmds.c
> @@ -78,6 +78,35 @@ static int print_qom_composition_child(Object *obj, void *opaque)
>       return 0;
>   }
>   
> +static int qom_composition_compare(const void *a, const void *b, void *ignore)
> +{
> +    Object *obja = (void *)a, *objb = (void *)b;

Casting away const...

> +    const char *namea, *nameb;
> +
> +    if (obja == object_get_root()) {
> +        namea = g_strdup("");
> +    } else {
> +        namea = object_get_canonical_path_component(obja);

...should we instead improve object_get_canonical_path_component to work 
with 'const Object *'?

> +    }
> +
> +    if (objb == object_get_root()) {
> +        nameb = g_strdup("");
> +    } else {
> +        nameb = object_get_canonical_path_component(objb);
> +    }
> +
> +
> +    return strcmp(namea, nameb);

Why the two blank lines?  This leaks namea and/or nameb if either object 
is the object root.  Should you instead use g_strcmp0 here, with namea/b 
set to NULL instead of g_strdup("") above?


> @@ -105,7 +134,16 @@ static void print_qom_composition(Monitor *mon, Object *obj, int indent)
>       monitor_printf(mon, "%*s/%s (%s)\n", indent, "", name,
>                      object_get_typename(obj));
>       g_free(name);
> -    object_child_foreach(obj, print_qom_composition_child, &s);
> +
> +    GQueue children;
> +    Object *child;

Mid-function declarations - I assume you'd clean this up if we want this 
for real?

> +    g_queue_init(&children);
> +    object_child_foreach(obj, insert_qom_composition_child, &children);
> +    while ((child = g_queue_pop_head(&children))) {
> +        print_qom_composition(mon, child, indent + 2);
> +    }
> +    (void)s;
> +    (void)print_qom_composition_child;

Also, this looks like leftover debugger aids?

>   }
>   
>   void hmp_info_qom_tree(Monitor *mon, const QDict *dict)
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2020-05-18 21:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18  5:19 [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization" Markus Armbruster
2020-05-18  5:19 ` [PATCH not-for-merge 1/5] qom: Instrument to detect missed realize Markus Armbruster
2020-05-18  5:19 ` [PATCH not-for-merge 2/5] qom: Make "info qom-tree" show children sorted Markus Armbruster
2020-05-18 21:04   ` Eric Blake [this message]
2020-05-19  6:43     ` Markus Armbruster
2020-05-18  5:19 ` [PATCH not-for-merge 3/5] qdev: Make "info qtree" show child devices sorted by QOM path Markus Armbruster
2020-05-18  5:19 ` [PATCH not-for-merge 4/5] qdev: Instrument to detect missed QOM parenting Markus Armbruster
2020-05-18  5:19 ` [PATCH not-for-merge 5/5] qdev: Instrument to detect bus mismatch Markus Armbruster
2020-05-18  6:54 ` [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization" no-reply
2020-05-18  7:08 ` no-reply
2020-05-18  7:27 ` no-reply
2020-05-18 20:56 ` Mark Cave-Ayland
2020-05-19  6:50   ` Markus Armbruster
2020-05-20 12:13 ` Philippe Mathieu-Daudé
2020-05-20 14:18   ` Markus Armbruster

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=c6eae4be-7d00-bc47-f5a0-4a5977136ac0@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).