[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH not-for-merge 3/5] qdev: Make "info qtree" show child devices sor
From: |
Markus Armbruster |
Subject: |
[PATCH not-for-merge 3/5] qdev: Make "info qtree" show child devices sorted by QOM path |
Date: |
Mon, 18 May 2020 07:19:43 +0200 |
"info qtree" shows children in reverse creation order. Show them
sorted by QOM path.
Signed-off-by: Markus Armbruster <address@hidden>
---
qdev-monitor.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index a4735d3bb1..07f78e9f5d 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -771,17 +771,43 @@ static void qdev_print(Monitor *mon, DeviceState *dev,
int indent)
}
}
+struct qbus_child {
+ DeviceState *dev;
+ char *qom_path;
+};
+
+static int dev_cmp(const void *a, const void *b)
+{
+ return g_strcmp0(((struct qbus_child *)a)->qom_path,
+ ((struct qbus_child *)b)->qom_path);
+}
+
static void qbus_print(Monitor *mon, BusState *bus, int indent)
{
BusChild *kid;
+ GSList *children = NULL;
qdev_printf("bus: %s\n", bus->name);
indent += 2;
qdev_printf("type %s\n", object_get_typename(OBJECT(bus)));
QTAILQ_FOREACH(kid, &bus->children, sibling) {
DeviceState *dev = kid->child;
- qdev_print(mon, dev, indent);
+ struct qbus_child *qc = g_malloc(sizeof(*qc));
+ qc->dev = dev;
+ qc->qom_path = object_get_canonical_path(OBJECT(dev));
+ children = g_slist_insert_sorted(children, qc, dev_cmp);
}
+ while (children) {
+ struct qbus_child *qc = children->data;
+ DeviceState *dev = qc->dev;
+ GSList *next = children->next;
+ qdev_print(mon, dev, indent);
+ g_free(qc->qom_path);
+ g_free(qc);
+ g_slist_free_1(children);
+ children = next;
+ }
+
}
#undef qdev_printf
--
2.21.1
- [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", Markus Armbruster, 2020/05/18
- [PATCH not-for-merge 1/5] qom: Instrument to detect missed realize, Markus Armbruster, 2020/05/18
- [PATCH not-for-merge 4/5] qdev: Instrument to detect missed QOM parenting, Markus Armbruster, 2020/05/18
- [PATCH not-for-merge 3/5] qdev: Make "info qtree" show child devices sorted by QOM path,
Markus Armbruster <=
- [PATCH not-for-merge 2/5] qom: Make "info qom-tree" show children sorted, Markus Armbruster, 2020/05/18
- [PATCH not-for-merge 5/5] qdev: Instrument to detect bus mismatch, Markus Armbruster, 2020/05/18
- Re: [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", no-reply, 2020/05/18
- Re: [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", no-reply, 2020/05/18
- Re: [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", no-reply, 2020/05/18
- Re: [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", Mark Cave-Ayland, 2020/05/18
- Re: [PATCH not-for-merge 0/5] Instrumentation for "Fixes around device realization", Philippe Mathieu-Daudé, 2020/05/20