Patchwork [10/25] Monitor: Convert monitor_print_cpus() into do_info_cpus()

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

Comments

Luiz Capitulino - Dec. 6, 2010, 6:23 p.m.
The new handler directly calls qmp_query_cpus() 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>
---
 monitor.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index f067d07..2164853 100644
--- a/monitor.c
+++ b/monitor.c
@@ -931,13 +931,13 @@  static void print_cpu_iter(QObject *obj, void *opaque)
     monitor_printf(mon, "\n");
 }
 
-static void monitor_print_cpus(Monitor *mon, const QObject *data)
+static void do_info_cpus(Monitor *mon)
 {
-    QList *cpu_list;
+    QObject *data;
 
-    assert(qobject_type(data) == QTYPE_QLIST);
-    cpu_list = qobject_to_qlist(data);
-    qlist_iter(cpu_list, print_cpu_iter, mon);
+    qmp_query_cpus(mon, &data);
+    qlist_iter(qobject_to_qlist(data), print_cpu_iter, mon);
+    qobject_decref(data);
 }
 
 static int do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
@@ -2430,8 +2430,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show infos for each CPU",
-        .user_print = monitor_print_cpus,
-        .mhandler.info_new = qmp_query_cpus,
+        .mhandler.info = do_info_cpus,
     },
     {
         .name       = "history",