All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 5/5] PCI: do_pci_info(): PCI bridge devices support
Date: Fri,  8 Jan 2010 16:42:16 -0200	[thread overview]
Message-ID: <1262976136-31852-6-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1262976136-31852-1-git-send-email-lcapitulino@redhat.com>

This commit completes the do_pci_info() conversion to
QObject by adding support to PCI bridge devices.

This is done by recursively adding devices in the
"pci_bridge" key.

IMPORTANT: This code is being added separately because I could
NOT test it properly. According to Michael Tsirkin, it depends
on ultrasparc and it would take time to do the proper setup.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/pci.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index d5e4866..82eec09 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1184,7 +1184,14 @@ static void pci_device_print(Monitor *mon, QDict *device)
 
     monitor_printf(mon, "      id \"%s\"\n", qdict_get_str(device, "qdev_id"));
 
-    /* TODO: PCI bridge devices */
+    if (qdict_haskey(device, "pci_bridge")) {
+        QListEntry *dev;
+
+        qdict = qdict_get_qdict(device, "pci_bridge");
+        QLIST_FOREACH_ENTRY(qdict_get_qlist(qdict, "devices"), dev) {
+            pci_device_print(mon, qobject_to_qdict(qlist_entry_obj(dev)));
+        }
+    }
 }
 
 void do_pci_info_print(Monitor *mon, const QObject *data)
@@ -1258,7 +1265,9 @@ static QObject *pci_get_regions_list(const PCIDevice *dev)
     return QOBJECT(regions_list);
 }
 
-static QObject *pci_get_dev_dict(PCIDevice *dev, int bus_num)
+static QObject *pci_get_devices_list(PCIBus *bus, int bus_num);
+
+static QObject *pci_get_dev_dict(PCIDevice *dev, PCIBus *bus, int bus_num)
 {
     int class;
     QObject *obj;
@@ -1297,6 +1306,12 @@ static QObject *pci_get_dev_dict(PCIDevice *dev, int bus_num)
         pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_SPACE_MEMORY |
                                 PCI_BASE_ADDRESS_MEM_PREFETCH));
 
+        if (dev->config[0x19] != 0) {
+            qdict = qobject_to_qdict(pci_bridge);
+            qdict_put_obj(qdict, "devices",
+                          pci_get_devices_list(bus, dev->config[0x19]));
+        }
+
         qdict = qobject_to_qdict(obj);
         qdict_put_obj(qdict, "pci_bridge", pci_bridge);
     }
@@ -1315,7 +1330,7 @@ static QObject *pci_get_devices_list(PCIBus *bus, int bus_num)
     for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
         dev = bus->devices[devfn];
         if (dev) {
-            qlist_append_obj(dev_list, pci_get_dev_dict(dev, bus_num));
+            qlist_append_obj(dev_list, pci_get_dev_dict(dev, bus, bus_num));
         }
     }
 
@@ -1368,6 +1383,7 @@ static QObject *pci_get_bus_dict(PCIBus *bus, int bus_num)
  *      - "io_range": a QDict with memory range information
  *      - "memory_range": a QDict with memory range information
  *      - "prefetchable_range": a QDict with memory range information
+ *      - "devices": a QList of PCI devices if there's any attached
  * - "regions": a QList of QDicts, each QDict represents a
  *   memory region of this device
  *
-- 
1.6.6

  parent reply	other threads:[~2010-01-08 18:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08 18:42 [Qemu-devel] [PATCH v1 0/5]: Convert pci_info() to QObject Luiz Capitulino
2010-01-08 18:42 ` [Qemu-devel] [PATCH 1/5] QList: Introduce QLIST_FOREACH_ENTRY() Luiz Capitulino
2010-01-08 18:42 ` [Qemu-devel] [PATCH 2/5] QDict: Introduce qdict_get_qdict() Luiz Capitulino
2010-01-08 18:42 ` [Qemu-devel] [PATCH 3/5] PCI: Convert pci_info() to QObject Luiz Capitulino
2010-01-18 17:16   ` Markus Armbruster
2010-01-19 20:27     ` Luiz Capitulino
2010-01-20  7:32       ` Markus Armbruster
2010-01-08 18:42 ` [Qemu-devel] [PATCH 4/5] PCI: do_pci_info(): PCI bridge support Luiz Capitulino
2010-01-18 17:14   ` Markus Armbruster
2010-01-19 20:11     ` Luiz Capitulino
2010-01-08 18:42 ` Luiz Capitulino [this message]
2010-01-18 17:16 ` [Qemu-devel] [PATCH v1 0/5]: Convert pci_info() to QObject Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2010-01-20 16:39 [Qemu-devel] [PATCH v2 " Luiz Capitulino
2010-01-20 16:39 ` [Qemu-devel] [PATCH 5/5] PCI: do_pci_info(): PCI bridge devices support Luiz Capitulino
2010-01-05 20:34 [Qemu-devel] [PATCH v0 0/5]: Convert pci_info() to QObject Luiz Capitulino
2010-01-05 20:34 ` [Qemu-devel] [PATCH 5/5] PCI: do_pci_info(): PCI bridge devices support Luiz Capitulino

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=1262976136-31852-6-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=mst@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 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.