Patchwork [19/25] Monitor: Convert do_info_name_print() into do_info_name()

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

Comments

Luiz Capitulino - Dec. 6, 2010, 6:24 p.m.
The new handler directly calls qmp_query_name() 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, 8 insertions(+), 4 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index 89325d8..2d1f183 100644
--- a/monitor.c
+++ b/monitor.c
@@ -754,16 +754,21 @@  static void qmp_query_name(Monitor *mon, QObject **ret_data)
                             qobject_from_jsonf("{}");
 }
 
-static void do_info_name_print(Monitor *mon, const QObject *data)
+static void do_info_name(Monitor *mon)
 {
     QDict *qdict;
+    QObject *data;
 
+    qmp_query_name(NULL, &data);
     qdict = qobject_to_qdict(data);
     if (qdict_size(qdict) == 0) {
-        return;
+        goto out;
     }
 
     monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name"));
+
+out:
+    qobject_decref(data);
 }
 
 static QObject *get_cmd_dict(const char *name)
@@ -2574,8 +2579,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM name",
-        .user_print = do_info_name_print,
-        .mhandler.info_new = qmp_query_name,
+        .mhandler.info = do_info_name,
     },
     {
         .name       = "uuid",