From a30bd8606ee1a3844dfecdc776a66e0516a77132 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Thu, 5 Jun 2014 07:09:13 +0200 Subject: [PATCH 4/9] PCI: do_pci_info(): PCI bridge devices support RH-Author: Marcel Apfelbaum Message-id: <1401952158-29608-3-git-send-email-marcel.a@redhat.com> Patchwork-id: 59148 O-Subject: [RHEL-6.6 qemu-kvm PATCH v5 2/7] PCI: do_pci_info(): PCI bridge devices support Bugzilla: 813748 RH-Acked-by: Michael S. Tsirkin RH-Acked-by: Laszlo Ersek RH-Acked-by: Luiz Capitulino 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 Signed-off-by: Anthony Liguori (cherry picked from commit d5e4acf7dfa1786c3825632362f5a73631d1eb55) Signed-off-by: Marcel Apfelbaum --- hw/pci.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) Signed-off-by: jen --- hw/pci.c | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 943601a..c87423b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1332,7 +1332,15 @@ 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")) { + qdict = qdict_get_qdict(device, "pci_bridge"); + if (qdict_haskey(qdict, "devices")) { + QListEntry *dev; + 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) @@ -1410,7 +1418,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; @@ -1449,6 +1459,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); } @@ -1467,7 +1483,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)); } } @@ -1520,6 +1536,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 (optional) * - "regions": a QList of QDicts, each QDict represents a * memory region of this device * -- 1.7.1