Patchwork [11/25] Monitor: Convert do_pci_info_print() into do_pci_info()

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 6, 2010, 6:23 p.m.
Message ID <1291659852-23028-12-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/74447/
State New
Headers show

Comments

Luiz Capitulino - Dec. 6, 2010, 6:23 p.m.
The new handler directly calls qmp_query_pci() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/pci.c  |    7 ++++++-
 hw/pci.h  |    2 +-
 monitor.c |    3 +--
 3 files changed, 8 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 08c36ec..ba204bf 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1276,9 +1276,12 @@  static void pci_device_print(Monitor *mon, QDict *device)
     }
 }
 
-void do_pci_info_print(Monitor *mon, const QObject *data)
+void do_pci_info(Monitor *mon)
 {
     QListEntry *bus, *dev;
+    QObject *data;
+
+    qmp_query_pci(NULL, &data);
 
     QLIST_FOREACH_ENTRY(qobject_to_qlist(data), bus) {
         QDict *qdict = qobject_to_qdict(qlist_entry_obj(bus));
@@ -1286,6 +1289,8 @@  void do_pci_info_print(Monitor *mon, const QObject *data)
             pci_device_print(mon, qobject_to_qdict(qlist_entry_obj(dev)));
         }
     }
+
+    qobject_decref(data);
 }
 
 static QObject *pci_get_dev_class(const PCIDevice *dev)
diff --git a/hw/pci.h b/hw/pci.h
index b87c6c0..22509dc 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -253,7 +253,7 @@  int pci_parse_devaddr(const char *addr, int *domp, int *busp,
 int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
-void do_pci_info_print(Monitor *mon, const QObject *data);
+void do_pci_info(Monitor *mon);
 void qmp_query_pci(Monitor *mon, QObject **ret_data);
 void pci_bridge_update_mappings(PCIBus *b);
 
diff --git a/monitor.c b/monitor.c
index 2164853..1fbe78b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2458,8 +2458,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show PCI info",
-        .user_print = do_pci_info_print,
-        .mhandler.info_new = qmp_query_pci,
+        .mhandler.info = do_pci_info,
     },
 #if defined(TARGET_I386) || defined(TARGET_SH4)
     {