qdev: add monitor command to dump the qdev/qbus tree.
PATCH 1/1 qdev: add monitor command to dump the qdev/qbus tree.
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
Quoted 1 line
From
a9796082f36381a85a2ec1427717f3d1202a3daaMon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
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 <[email protected]>
--- hw/pci.c | 6 ++++++ hw/qdev.c | 22 ++++++++++++++++++++++ hw/qdev.h | 8 ++++++++ monitor.c | 5 +++++ 4 files changed, 41 insertions(+), 0 deletions(-)
hw/pci.c +6 -0
@@ -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 ); +}
hw/qdev.c +22 -0
@@ -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 ); +}
hw/qdev.h +8 -0
@@ -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
monitor.c +5 -0
@@ -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, }, };
Signature · 1 line
1.6.2.2