All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: philmd@redhat.com, mark.cave-ayland@ilande.co.uk,
	berrange@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com
Subject: Re: [PATCH 2/2] qom: Make "info qom-tree" show children sorted
Date: Wed, 27 May 2020 11:04:06 +0200	[thread overview]
Message-ID: <a8313e39-169d-f2ed-09bc-8d51aec322be@kaod.org> (raw)
In-Reply-To: <20200527084754.7531-3-armbru@redhat.com>

On 5/27/20 10:47 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. Thanks for fixing that.

 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

I used the powernv9 machine.

Tested-by: Cédric Le Goater <clg@kaod.org>

> ---
>  qom/qom-hmp-cmds.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> index cd08233a4c..94bdee9a90 100644
> --- a/qom/qom-hmp-cmds.c
> +++ b/qom/qom-hmp-cmds.c
> @@ -69,22 +69,25 @@ typedef struct QOMCompositionState {
>  
>  static void print_qom_composition(Monitor *mon, Object *obj, int indent);
>  
> -static int print_qom_composition_child(Object *obj, void *opaque)
> +static int qom_composition_compare(const void *a, const void *b, void *ignore)
>  {
> -    QOMCompositionState *s = opaque;
> +    return g_strcmp0(a ? object_get_canonical_path_component(a) : NULL,
> +                     b ? object_get_canonical_path_component(b) : NULL);
> +}
>  
> -    print_qom_composition(s->mon, obj, s->indent);
> +static int insert_qom_composition_child(Object *obj, void *opaque)
> +{
> +    GQueue *children = opaque;
>  
> +    g_queue_insert_sorted(children, obj, qom_composition_compare, NULL);
>      return 0;
>  }
>  
>  static void print_qom_composition(Monitor *mon, Object *obj, int indent)
>  {
> -    QOMCompositionState s = {
> -        .mon = mon,
> -        .indent = indent + 2,
> -    };
>      char *name;
> +    GQueue children;
> +    Object *child;
>  
>      if (obj == object_get_root()) {
>          name = g_strdup("");
> @@ -94,7 +97,12 @@ 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);
> +
> +    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 hmp_info_qom_tree(Monitor *mon, const QDict *dict)
> 



  reply	other threads:[~2020-05-27  9:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27  8:47 [PATCH 0/2] qom: Make "info qom-tree" show children sorted Markus Armbruster
2020-05-27  8:47 ` [PATCH 1/2] qom: Constify object_get_canonical_path{, _component}()'s parameter Markus Armbruster
2020-05-27  9:02   ` Cédric Le Goater
2020-05-27  9:49   ` [PATCH 1/2] qom: Constify object_get_canonical_path{,_component}()'s parameter Philippe Mathieu-Daudé
2020-05-27  8:47 ` [PATCH 2/2] qom: Make "info qom-tree" show children sorted Markus Armbruster
2020-05-27  9:04   ` Cédric Le Goater [this message]
2020-05-27 10:31   ` Philippe Mathieu-Daudé
2020-07-07  4:45   ` Slow down with: 'Make "info qom-tree" show children sorted' Thomas Huth
2020-07-07  4:58     ` Philippe Mathieu-Daudé
2020-07-07  5:33       ` Markus Armbruster
2020-07-07  8:00         ` Paolo Bonzini
2020-07-07 12:00           ` Markus Armbruster
2020-07-07 12:04             ` Daniel P. Berrangé
2020-07-13  1:13             ` David Gibson
2020-07-13 16:13               ` Markus Armbruster
2020-07-15 23:59                 ` David Gibson
2020-07-16  5:37                   ` Markus Armbruster
2020-07-17  6:00                     ` David Gibson
2020-07-07  8:46     ` Daniel P. Berrangé
2020-07-07  9:06       ` Paolo Bonzini
2020-07-07  9:40     ` Daniel P. Berrangé
2020-07-07  9:49       ` Paolo Bonzini
2020-07-08  9:24       ` Markus Armbruster
2020-06-08 12:09 ` [PATCH 0/2] qom: Make "info qom-tree" show children sorted Mark Cave-Ayland

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=a8313e39-169d-f2ed-09bc-8d51aec322be@kaod.org \
    --to=clg@kaod.org \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=philmd@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 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.