From patchwork Fri Mar 26 08:07:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 48617 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 07BB1B7CBD for ; Fri, 26 Mar 2010 19:21:03 +1100 (EST) Received: from localhost ([127.0.0.1]:48765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nv4mq-0006a7-3u for incoming@patchwork.ozlabs.org; Fri, 26 Mar 2010 04:21:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nv4Zc-0003QE-Bt for qemu-devel@nongnu.org; Fri, 26 Mar 2010 04:07:20 -0400 Received: from [140.186.70.92] (port=55297 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nv4Za-0003PH-2g for qemu-devel@nongnu.org; Fri, 26 Mar 2010 04:07:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nv4ZW-0003EU-Uf for qemu-devel@nongnu.org; Fri, 26 Mar 2010 04:07:17 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:53760) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nv4ZW-0003Ds-JT for qemu-devel@nongnu.org; Fri, 26 Mar 2010 04:07:14 -0400 Received: from blackfin.pond.sub.org (pD9E38AC7.dip.t-dialin.net [217.227.138.199]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 4E819276DA9 for ; Fri, 26 Mar 2010 09:07:12 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 9718BDB; Fri, 26 Mar 2010 09:07:11 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 26 Mar 2010 09:07:09 +0100 Message-Id: <1269590831-26185-3-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1269590831-26185-1-git-send-email-armbru@redhat.com> References: <1269590831-26185-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v2 2/4] 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 This is a boolean value. Human monitor accepts "on" or "off". Consistent with option parsing (see parse_option_bool()). Signed-off-by: Markus Armbruster --- monitor.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index 3ce9a4e..389485d 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') * */ @@ -3841,6 +3843,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; @@ -4322,6 +4347,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) {