From patchwork Thu Oct 1 15:50:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 34749 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 7490FB7B89 for ; Fri, 2 Oct 2009 02:24:58 +1000 (EST) Received: from localhost ([127.0.0.1]:50353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtOSd-0002OQ-Ja for incoming@patchwork.ozlabs.org; Thu, 01 Oct 2009 12:24:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtNwb-000805-Fu for qemu-devel@nongnu.org; Thu, 01 Oct 2009 11:51:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtNwW-0007rh-C1 for qemu-devel@nongnu.org; Thu, 01 Oct 2009 11:51:48 -0400 Received: from [199.232.76.173] (port=54700 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtNwW-0007r9-3r for qemu-devel@nongnu.org; Thu, 01 Oct 2009 11:51:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33331) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtNwV-0003gQ-Il for qemu-devel@nongnu.org; Thu, 01 Oct 2009 11:51:43 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n91FpgHS008826; Thu, 1 Oct 2009 11:51:42 -0400 Received: from localhost (vpn-12-143.rdu.redhat.com [10.11.12.143]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n91FpfSQ020356; Thu, 1 Oct 2009 11:51:42 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 1 Oct 2009 12:50:45 -0300 Message-Id: <1254412245-10452-15-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1254412245-10452-1-git-send-email-lcapitulino@redhat.com> References: <1254412245-10452-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com Subject: [Qemu-devel] [PATCH 14/14] monitor: Convert do_info_balloon() to QObject 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 On success return a QInt with the balloon's value, on error MonitorError is properly filled. This also introduces monitor_print_balloon() to print the balloon information in the user protocol format and monitor_print_error(), which can be used as a standard way to print error descriptions in the user protocol format. Signed-off-by: Luiz Capitulino --- monitor.c | 35 +++++++++++++++++++++++++---------- 1 files changed, 25 insertions(+), 10 deletions(-) diff --git a/monitor.c b/monitor.c index 1b52355..2cf9f7e 100644 --- a/monitor.c +++ b/monitor.c @@ -265,6 +265,11 @@ static void monitor_print_qobject(Monitor *mon, const QObject *data) monitor_puts(mon, "\n"); } +static void monitor_print_error(Monitor *mon, const MonitorError *error) +{ + monitor_print_qobject(mon, QOBJECT(error->desc)); +} + static int compare_cmd(const char *name, const char *list) { const char *p, *pstart; @@ -1669,18 +1674,28 @@ static void do_balloon(Monitor *mon, const QDict *qdict, QObject **ret_data, qemu_balloon(target << 20); } -static void do_info_balloon(Monitor *mon) +static void monitor_print_balloon(Monitor *mon, const QObject *data) +{ + monitor_printf(mon, "balloon: actual=%d\n", + (int)qint_get_int(qobject_to_qint(data))); +} + +/** + * do_info_balloon(): Balloon information + */ +static void do_info_balloon(Monitor *mon, QObject **ret_data, + MonitorError *error) { ram_addr_t actual; actual = qemu_balloon_status(); - if (kvm_enabled() && !kvm_has_sync_mmu()) - monitor_printf(mon, "Using KVM without synchronous MMU, " - "ballooning disabled\n"); - else if (actual == 0) - monitor_printf(mon, "Ballooning not activated in VM\n"); - else - monitor_printf(mon, "balloon: actual=%d\n", (int)(actual >> 20)); + if (kvm_enabled() && !kvm_has_sync_mmu()) { + monitor_error_set_code(error, MON_ERR_BAL_MMU); + } else if (actual == 0) { + monitor_error_set_code(error, MON_ERR_BAL_DIS); + } else { + *ret_data = QOBJECT(qint_from_int((int)(actual >> 20))); + } } static qemu_acl *find_acl(Monitor *mon, const char *name) @@ -2203,8 +2218,8 @@ static const mon_cmd_t info_cmds[] = { .name = "balloon", .args_type = "", .handler = do_info_balloon, - .user_print = NULL, - .user_error = NULL, + .user_print = monitor_print_balloon, + .user_error = monitor_print_error, .params = "", .help = "show balloon information" },