* [Qemu-devel] [PATCH] qdev: add monitor command to dump the qdev/qbus tree.
@ 2009-05-28 11:36 Gerd Hoffmann
0 siblings, 0 replies; only message in thread
From: Gerd Hoffmann @ 2009-05-28 11:36 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 332 bytes --]
Hi,
Found that useful while playing with qdev.
Adds a "info qtree" command which prints the device tree. Prints
nothing right now (on x86_64) due to the tree being incomplete.
Also adds "info qtreepci". Intended to be temporary only until pci is
hooked up properly and thus printed by "info qtree".
please apply,
Gerd
[-- Attachment #2: 0005-qdev-add-monitor-command-to-dump-the-tree.patch --]
[-- Type: text/plain, Size: 2825 bytes --]
>From a9796082f36381a85a2ec1427717f3d1202a3daa Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 27 May 2009 14:21:53 +0200
Subject: [PATCH 05/21] qdev: add monitor command to dump the tree.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pci.c | 6 ++++++
hw/qdev.c | 22 ++++++++++++++++++++++
hw/qdev.h | 8 ++++++++
monitor.c | 5 +++++
4 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 0ab5b94..7e2e73f 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -947,3 +947,9 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
return (PCIDevice *)dev;
}
+
+void do_info_qtreepci(Monitor *mon)
+{
+ if (first_bus)
+ qbus_print(mon, &first_bus->qbus, 0);
+}
diff --git a/hw/qdev.c b/hw/qdev.c
index cedb772..d2eeb9a 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -29,6 +29,7 @@
#include "net.h"
#include "qdev.h"
#include "sysemu.h"
+#include "monitor.h"
struct DeviceProperty {
const char *name;
@@ -312,3 +313,24 @@ BusState *qbus_create(BusType type, size_t size,
}
return bus;
}
+
+void qbus_print(Monitor *mon, BusState *bus, int indent)
+{
+ struct DeviceState *dev;
+ struct BusState *child;
+
+ monitor_printf(mon, "%*sbus: name %s, type %d\n", indent, "",
+ bus->name, bus->type);
+ LIST_FOREACH(dev, &bus->children, sibling) {
+ monitor_printf(mon, "%*sdev: %s\n", indent+2, "", dev->type->name);
+ LIST_FOREACH(child, &dev->child_bus, sibling) {
+ qbus_print(mon, child, indent+4);
+ }
+ }
+}
+
+void do_info_qtree(Monitor *mon)
+{
+ if (main_system_bus)
+ qbus_print(mon, main_system_bus, 0);
+}
diff --git a/hw/qdev.h b/hw/qdev.h
index b3cc3ec..0842d3b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -102,4 +102,12 @@ BusState *qbus_create(BusType type, size_t size,
#define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
+/*** monitor commands ***/
+
+void qbus_print(Monitor *mon, BusState *bus, int indent);
+void do_info_qtree(Monitor *mon);
+
+/* temporary hack, pci_bus isn't hooked up anywhere (yet) */
+void do_info_qtreepci(Monitor *mon);
+
#endif
diff --git a/monitor.c b/monitor.c
index 0f38c71..a2d4e3d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -23,6 +23,7 @@
*/
#include <dirent.h>
#include "hw/hw.h"
+#include "hw/qdev.h"
#include "hw/usb.h"
#include "hw/pcmcia.h"
#include "hw/pc.h"
@@ -1852,6 +1853,10 @@ static const mon_cmd_t info_cmds[] = {
{ "migrate", "", do_info_migrate, "", "show migration status" },
{ "balloon", "", do_info_balloon,
"", "show balloon information" },
+ { "qtree", "", do_info_qtree,
+ "", "show device tree" },
+ { "qtreepci", "", do_info_qtreepci,
+ "", "show pci device tree" },
{ NULL, NULL, },
};
--
1.6.2.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-28 11:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-28 11:36 [Qemu-devel] [PATCH] qdev: add monitor command to dump the qdev/qbus tree Gerd Hoffmann
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.