[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/84] qom: Make "info qom-tree" show children sorted
From: |
Markus Armbruster |
Subject: |
[PULL 02/84] qom: Make "info qom-tree" show children sorted |
Date: |
Mon, 15 Jun 2020 22:38:46 +0200 |
"info qom-tree" prints children in unstable order. This is a pain
when diffing output for different versions to find change. Print it
sorted.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200527084754.7531-3-armbru@redhat.com>
Tested-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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 f704b6949a..99385b6ad2 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -81,22 +81,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("");
@@ -106,7 +109,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)
--
2.26.2
- [PULL 00/84] QOM patches for 2020-06-15, Markus Armbruster, 2020/06/15
- [PULL 02/84] qom: Make "info qom-tree" show children sorted,
Markus Armbruster <=
- [PULL 06/84] arm/aspeed: Compute the number of CPUs from the SoC definition, Markus Armbruster, 2020/06/15
- [PULL 04/84] display/xlnx_dp: Fix to realize "i2c-ddc" and "aux-to-i2c-bridge", Markus Armbruster, 2020/06/15
- [PULL 07/84] arm/aspeed: Rework NIC attachment, Markus Armbruster, 2020/06/15
- [PULL 05/84] sd/pxa2xx_mmci: Fix to realize "pxa2xx-mmci" device, Markus Armbruster, 2020/06/15
- [PULL 16/84] macio: Put "macio-nvram" device on the macio bus, Markus Armbruster, 2020/06/15
- [PULL 10/84] mac_via: Fix to realize "mos6522-q800-via*" devices, Markus Armbruster, 2020/06/15
- [PULL 09/84] auxbus: Fix aux-to-i2c-bridge to be a subtype of aux-slave, Markus Armbruster, 2020/06/15
- [PULL 24/84] qdev: Assert devices are plugged into a bus that can take them, Markus Armbruster, 2020/06/15