From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9duK-0002YP-Ik for qemu-devel@nongnu.org; Thu, 28 May 2009 07:36:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9duF-0002XU-D4 for qemu-devel@nongnu.org; Thu, 28 May 2009 07:36:23 -0400 Received: from [199.232.76.173] (port=56681 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9duF-0002XR-8b for qemu-devel@nongnu.org; Thu, 28 May 2009 07:36:19 -0400 Received: from mx2.redhat.com ([66.187.237.31]:33151) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M9duE-00065a-M8 for qemu-devel@nongnu.org; Thu, 28 May 2009 07:36:19 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4SBaIeD029435 for ; Thu, 28 May 2009 07:36:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4SBaHK2021721 for ; Thu, 28 May 2009 07:36:17 -0400 Received: from zweiblum.home.kraxel.org (vpn-10-220.str.redhat.com [10.32.10.220]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4SBaFGJ016477 for ; Thu, 28 May 2009 07:36:15 -0400 Message-ID: <4A1E772E.3020307@redhat.com> Date: Thu, 28 May 2009 13:36:14 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080309000405090001000809" Subject: [Qemu-devel] [PATCH] qdev: add monitor command to dump the qdev/qbus tree. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" This is a multi-part message in MIME format. --------------080309000405090001000809 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------080309000405090001000809 Content-Type: text/plain; name="0005-qdev-add-monitor-command-to-dump-the-tree.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0005-qdev-add-monitor-command-to-dump-the-tree.patch" >>From a9796082f36381a85a2ec1427717f3d1202a3daa Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann 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 --- 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 #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 --------------080309000405090001000809--