diff mbox

[17/25] Monitor: Convert do_info_vnc_print() into do_info_vnc()

Message ID 1291659852-23028-18-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Dec. 6, 2010, 6:24 p.m. UTC
The new handler directly calls qmp_query_vnc() 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>
---
 console.h |    2 +-
 monitor.c |    3 +--
 ui/vnc.c  |    9 +++++++--
 3 files changed, 9 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/console.h b/console.h
index 232714b..c72f612 100644
--- a/console.h
+++ b/console.h
@@ -369,7 +369,7 @@  void vnc_display_init(DisplayState *ds);
 void vnc_display_close(DisplayState *ds);
 int vnc_display_open(DisplayState *ds, const char *display);
 int vnc_display_password(DisplayState *ds, const char *password);
-void do_info_vnc_print(Monitor *mon, const QObject *data);
+void do_info_vnc(Monitor *mon);
 void qmp_query_vnc(Monitor *mon, QObject **ret_data);
 char *vnc_display_local_addr(DisplayState *ds);
 
diff --git a/monitor.c b/monitor.c
index 3b86076..59b3866 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2567,8 +2567,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the vnc server status",
-        .user_print = do_info_vnc_print,
-        .mhandler.info_new = qmp_query_vnc,
+        .mhandler.info = do_info_vnc,
     },
     {
         .name       = "name",
diff --git a/ui/vnc.c b/ui/vnc.c
index 4674f5e..51f6db4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -302,15 +302,17 @@  static void info_vnc_iter(QObject *obj, void *opaque)
 #endif
 }
 
-void do_info_vnc_print(Monitor *mon, const QObject *data)
+void do_info_vnc(Monitor *mon)
 {
     QDict *server;
     QList *clients;
+    QObject *data;
 
+    qmp_query_vnc(NULL, &data);
     server = qobject_to_qdict(data);
     if (qdict_get_bool(server, "enabled") == 0) {
         monitor_printf(mon, "Server: disabled\n");
-        return;
+        goto out;
     }
 
     monitor_printf(mon, "Server:\n");
@@ -325,6 +327,9 @@  void do_info_vnc_print(Monitor *mon, const QObject *data)
     } else {
         qlist_iter(clients, info_vnc_iter, mon);
     }
+
+out:
+    qobject_decref(data);
 }
 
 void qmp_query_vnc(Monitor *mon, QObject **ret_data)