Received: from [140.186.70.92] (port=36314 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPfkD-0003Qk-Ep for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPfkC-0004Je-9q for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:25:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPfkC-0004JT-2Z for qemu-devel@nongnu.org; Mon, 06 Dec 2010 13:25:00 -0500 From: Luiz Capitulino Date: Mon, 6 Dec 2010 16:24:11 -0200 Message-Id: <1291659852-23028-25-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1291659852-23028-1-git-send-email-lcapitulino@redhat.com> References: <1291659852-23028-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, armbru@redhat.com 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 --- 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