From patchwork Mon Dec 5 20:00:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 129417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 55A021007D5 for ; Tue, 6 Dec 2011 07:21:08 +1100 (EST) Received: from localhost ([::1]:40696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXejW-0004uQ-2I for incoming@patchwork.ozlabs.org; Mon, 05 Dec 2011 15:01:50 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXeig-00038q-SM for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:01:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXeie-00062H-IN for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:00:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXeie-00062A-6w for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:00:56 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB5K0nXi006906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Dec 2011 15:00:49 -0500 Received: from localhost (ovpn-113-50.phx2.redhat.com [10.3.113.50]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB5K0mtQ012188; Mon, 5 Dec 2011 15:00:49 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 5 Dec 2011 18:00:20 -0200 Message-Id: <1323115226-16817-11-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1323115226-16817-1-git-send-email-lcapitulino@redhat.com> References: <1323115226-16817-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 10/16] qapi: Convert balloon X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Note that the command being dropped uses the deprecated MONITOR_CMD_ASYNC API, but the new command is a regular synchronous command. There shouldn't be visible differences though, as MONITOR_CMD_ASYNC is internal only. Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino --- balloon.c | 28 ++++++++-------------------- balloon.h | 3 --- hmp-commands.hx | 4 +--- hmp.c | 12 ++++++++++++ hmp.h | 1 + qapi-schema.json | 20 ++++++++++++++++++++ qmp-commands.hx | 6 +----- 7 files changed, 43 insertions(+), 31 deletions(-) diff --git a/balloon.c b/balloon.c index e1cd5fa..0166744 100644 --- a/balloon.c +++ b/balloon.c @@ -100,31 +100,19 @@ BalloonInfo *qmp_query_balloon(Error **errp) return info; } -/** - * do_balloon(): Request VM to change its memory allocation - */ -int do_balloon(Monitor *mon, const QDict *params, - MonitorCompletion cb, void *opaque) +void qmp_balloon(int64_t value, Error **errp) { - int64_t target; - int ret; - if (kvm_enabled() && !kvm_has_sync_mmu()) { - qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); - return -1; + error_set(errp, QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); + return; } - target = qdict_get_int(params, "value"); - if (target <= 0) { + if (value <= 0) { qerror_report(QERR_INVALID_PARAMETER_VALUE, "target", "a size"); - return -1; + return; } - ret = qemu_balloon(target); - if (ret == 0) { - qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon"); - return -1; + + if (qemu_balloon(value) == 0) { + error_set(errp, QERR_DEVICE_NOT_ACTIVE, "balloon"); } - - cb(opaque, NULL); - return 0; } diff --git a/balloon.h b/balloon.h index b36abea..b60fd5d 100644 --- a/balloon.h +++ b/balloon.h @@ -24,7 +24,4 @@ int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, QEMUBalloonStatus *stat_func, void *opaque); void qemu_remove_balloon_handler(void *opaque); -int do_balloon(Monitor *mon, const QDict *params, - MonitorCompletion cb, void *opaque); - #endif diff --git a/hmp-commands.hx b/hmp-commands.hx index 0bf8896..ea52271 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1022,9 +1022,7 @@ ETEXI .args_type = "value:M", .params = "target", .help = "request VM to change its memory allocation (in MB)", - .user_print = monitor_user_noop, - .mhandler.cmd_async = do_balloon, - .flags = MONITOR_CMD_ASYNC, + .mhandler.cmd = hmp_balloon, }, STEXI diff --git a/hmp.c b/hmp.c index 3893d59..e9d1711 100644 --- a/hmp.c +++ b/hmp.c @@ -621,3 +621,15 @@ void hmp_block_passwd(Monitor *mon, const QDict *qdict) qmp_block_passwd(device, password, &errp); hmp_handle_error(mon, &errp); } + +void hmp_balloon(Monitor *mon, const QDict *qdict) +{ + int64_t value = qdict_get_int(qdict, "value"); + Error *errp = NULL; + + qmp_balloon(value, &errp); + if (error_is_set(&errp)) { + monitor_printf(mon, "balloon: %s\n", error_get_pretty(errp)); + error_free(errp); + } +} diff --git a/hmp.h b/hmp.h index d6aa232..b0984ac 100644 --- a/hmp.h +++ b/hmp.h @@ -43,5 +43,6 @@ void hmp_cont(Monitor *mon, const QDict *qdict); void hmp_inject_nmi(Monitor *mon, const QDict *qdict); void hmp_set_link(Monitor *mon, const QDict *qdict); void hmp_block_passwd(Monitor *mon, const QDict *qdict); +void hmp_balloon(Monitor *mon, const QDict *qdict); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 569aa74..9bfdc39 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1032,3 +1032,23 @@ # Since: 0.14.0 ## { 'command': 'block_passwd', 'data': {'device': 'str', 'password': 'str'} } + +## +# @balloon: +# +# Request the balloon driver to change its balloon size. +# +# @value: the target size of the balloon in bytes +# +# Returns: Nothing on success +# If the balloon driver is enabled but not functional because the KVM +# kernel module cannot support it, KvmMissingCap +# If no balloon device is present, DeviceNotActive +# +# Notes: This command just issues a request to the guest. When it returns, +# the balloon size may not have changed. A guest can change the balloon +# size independent of this command. +# +# Since: 0.14.0 +## +{ 'command': 'balloon', 'data': {'value': 'int'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index bbf9bfc..7c377f0 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -703,11 +703,7 @@ EQMP { .name = "balloon", .args_type = "value:M", - .params = "target", - .help = "request VM to change its memory allocation (in MB)", - .user_print = monitor_user_noop, - .mhandler.cmd_async = do_balloon, - .flags = MONITOR_CMD_ASYNC, + .mhandler.cmd_new = qmp_marshal_input_balloon, }, SQMP