diff mbox

[24/25] Monitor: Introduce do_info_balloon()

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

Commit Message

Luiz Capitulino Dec. 6, 2010, 6:24 p.m. UTC
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 <lcapitulino@redhat.com>
---
 monitor.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
diff mbox

Patch

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",