From patchwork Mon Apr 5 20:33:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 49442 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 97942B7D15 for ; Tue, 6 Apr 2010 07:12:46 +1000 (EST) Received: from localhost ([127.0.0.1]:47814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NytMK-0006rm-Pz for incoming@patchwork.ozlabs.org; Mon, 05 Apr 2010 16:57:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nyt3A-0002ES-4B for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:37:36 -0400 Received: from [140.186.70.92] (port=49526 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nyt2p-0001XC-Oi for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nyt0V-0001eY-8z for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42175) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nyt0V-0001eS-0z for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:51 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYo9A024435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Apr 2010 16:34:50 -0400 Received: from localhost (vpn-8-191.rdu.redhat.com [10.11.8.191]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYm8k025709; Mon, 5 Apr 2010 16:34:49 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 5 Apr 2010 17:33:57 -0300 Message-Id: <1270499642-31543-17-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> References: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Luiz Capitulino , qemu-devel@nongnu.org, Markus Armbruster Subject: [Qemu-devel] [PATCH 16/21] monitor: New argument type 'b' 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 From: Markus Armbruster This is a boolean value. Human monitor accepts "on" or "off". Consistent with option parsing (see parse_option_bool()). Signed-off-by: Markus Armbruster Signed-off-by: Luiz Capitulino --- monitor.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index d3b360c..c5a4dbf 100644 --- a/monitor.c +++ b/monitor.c @@ -85,6 +85,8 @@ * * '?' optional type (for all types, except '/') * '.' other form of optional type (for 'i' and 'l') + * 'b' boolean + * user mode accepts "on" or "off" * '-' optional parameter (eg. '-f') * */ @@ -3842,6 +3844,29 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, qdict_put(qdict, key, qfloat_from_double(val)); } break; + case 'b': + { + const char *beg; + int val; + + while (qemu_isspace(*p)) { + p++; + } + beg = p; + while (qemu_isgraph(*p)) { + p++; + } + if (p - beg == 2 && !memcmp(beg, "on", p - beg)) { + val = 1; + } else if (p - beg == 3 && !memcmp(beg, "off", p - beg)) { + val = 0; + } else { + monitor_printf(mon, "Expected 'on' or 'off'\n"); + goto fail; + } + qdict_put(qdict, key, qbool_from_int(val)); + } + break; case '-': { const char *tmp = p; @@ -4323,6 +4348,12 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args) return -1; } break; + case 'b': + if (qobject_type(value) != QTYPE_QBOOL) { + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "bool"); + return -1; + } + break; case '-': if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QBOOL) {