From patchwork Mon Dec 6 18:24:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 74449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0D3EBB70CD for ; Tue, 7 Dec 2010 05:46:44 +1100 (EST) Received: from localhost ([127.0.0.1]:43819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPg5A-0005lw-UW for incoming@patchwork.ozlabs.org; Mon, 06 Dec 2010 13:46:41 -0500 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 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6IOx2s012776 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 13:24:59 -0500 Received: from localhost ([10.3.113.17]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB6IOwqD007204; Mon, 6 Dec 2010 13:24:58 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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",