Patchwork [05/25] Monitor: Convert do_info_version_print() into do_info_version()

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

Comments

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

Patch

diff --git a/monitor.c b/monitor.c
index 6252b3f..56575a6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -730,11 +730,12 @@  static void qmp_query_version(Monitor *mon, QObject **ret_data)
         'micro': %d }, 'package': %s }", major, minor, micro, QEMU_PKGVERSION);
 }
 
-static void do_info_version_print(Monitor *mon, const QObject *data)
+static void do_info_version(Monitor *mon)
 {
-    QDict *qdict;
-    QDict *qemu;
+    QDict *qdict, *qemu;
+    QObject *data;
 
+    qmp_query_version(NULL, &data);
     qdict = qobject_to_qdict(data);
     qemu = qdict_get_qdict(qdict, "qemu");
 
@@ -743,6 +744,8 @@  static void do_info_version_print(Monitor *mon, const QObject *data)
                   qdict_get_int(qemu, "minor"),
                   qdict_get_int(qemu, "micro"),
                   qdict_get_str(qdict, "package"));
+
+    qobject_decref(data);
 }
 
 static void do_info_name_print(Monitor *mon, const QObject *data)
@@ -2385,8 +2388,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .user_print = do_info_version_print,
-        .mhandler.info_new = qmp_query_version,
+        .mhandler.info = do_info_version,
     },
     {
         .name       = "network",