qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] qdev: add monitor command to dump the qdev/qbus tree.
Date: Thu, 28 May 2009 13:36:14 +0200	[thread overview]
Message-ID: <4A1E772E.3020307@redhat.com> (raw)

[-- 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


                 reply	other threads:[~2009-05-28 11:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A1E772E.3020307@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).