Patchwork [16/25] Monitor: Convert do_info_mice_print() into do_info_mice()

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

Comments

Luiz Capitulino - Dec. 6, 2010, 6:24 p.m.
The new handler directly calls qmp_query_mice() 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 +-
 input.c   |    9 +++++++--
 monitor.c |    3 +--
 3 files changed, 9 insertions(+), 5 deletions(-)

Patch

diff --git a/console.h b/console.h
index f613e4e..232714b 100644
--- a/console.h
+++ b/console.h
@@ -72,7 +72,7 @@  struct MouseTransformInfo {
     int a[7];
 };
 
-void do_info_mice_print(Monitor *mon, const QObject *data);
+void do_info_mice(Monitor *mon);
 void qmp_query_mice(Monitor *mon, QObject **ret_data);
 void do_mouse_set(Monitor *mon, const QDict *qdict);
 
diff --git a/input.c b/input.c
index a3ea9c2..cbe0074 100644
--- a/input.c
+++ b/input.c
@@ -207,17 +207,22 @@  static void info_mice_iter(QObject *data, void *opaque)
                    qdict_get_bool(mouse, "absolute") ? " (absolute)" : "");
 }
 
-void do_info_mice_print(Monitor *mon, const QObject *data)
+void do_info_mice(Monitor *mon)
 {
     QList *mice_list;
+    QObject *data;
 
+    qmp_query_mice(NULL, &data);
     mice_list = qobject_to_qlist(data);
     if (qlist_empty(mice_list)) {
         monitor_printf(mon, "No mouse devices connected\n");
-        return;
+        goto out;
     }
 
     qlist_iter(mice_list, info_mice_iter, mon);
+
+out:
+    qobject_decref(data);
 }
 
 void qmp_query_mice(Monitor *mon, QObject **ret_data)
diff --git a/monitor.c b/monitor.c
index 445c73a..3b86076 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2560,8 +2560,7 @@  static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show which guest mouse is receiving events",
-        .user_print = do_info_mice_print,
-        .mhandler.info_new = qmp_query_mice,
+        .mhandler.info = do_info_mice,
     },
     {
         .name       = "vnc",