qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon()


From: Luiz Capitulino
Subject: [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon()
Date: Mon, 6 Dec 2010 16:24:11 -0200

Today, the do_info() function takes care of handling asynchronous
calls. But what we really want is to move all the asynchronous
stuff behind the (future) QMP API.

The QMP API will be directly used by handlers, and won't be tied to
the human monitor common code (like do_info()) in any way.

This commit takes the first step towards this goal: it introduces
do_info_ballon(), which is a regular info handler, except that it
knows how to directly call an asynchronous QMP handler.

Signed-off-by: Luiz Capitulino <address@hidden>
---
 monitor.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 97bab21..d07608e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -714,6 +714,22 @@ help:
     help_cmd(mon, "info");
 }
 
+static void do_info_balloon(Monitor *mon)
+{
+    int err;
+    MonitorCompletionData *cb_data;
+
+    cb_data = qemu_malloc(sizeof(*cb_data));
+    cb_data->mon = mon;
+    cb_data->user_print = monitor_print_balloon;
+    monitor_suspend(mon);
+    err = qmp_query_balloon(NULL, user_monitor_complete, cb_data);
+    if (err < 0) {
+        monitor_resume(mon);
+        qemu_free(cb_data);
+    }
+}
+
 static void qmp_query_version(Monitor *mon, QObject **ret_data)
 {
     const char *version = QEMU_VERSION;
@@ -2622,9 +2638,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show balloon information",
-        .user_print = monitor_print_balloon,
-        .mhandler.info_async = qmp_query_balloon,
-        .flags      = MONITOR_CMD_ASYNC,
+        .mhandler.info = do_info_balloon,
     },
     {
         .name       = "qtree",
-- 
1.7.3.3.398.g0b0cd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]