From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuWIs-0006xq-Ph for qemu-devel@nongnu.org; Wed, 24 Mar 2010 15:31:46 -0400 Received: from [140.186.70.92] (port=56325 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuWIr-0006x8-0l for qemu-devel@nongnu.org; Wed, 24 Mar 2010 15:31:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuWIp-00082v-CI for qemu-devel@nongnu.org; Wed, 24 Mar 2010 15:31:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23523) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuWIp-00082r-2W for qemu-devel@nongnu.org; Wed, 24 Mar 2010 15:31:43 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2OJVg7N026026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Mar 2010 15:31:42 -0400 Date: Wed, 24 Mar 2010 16:31:36 -0300 From: Luiz Capitulino Message-ID: <20100324163136.2a3a5ab5@redhat.com> In-Reply-To: <1269340078-16446-3-git-send-email-armbru@redhat.com> References: <1269340078-16446-1-git-send-email-armbru@redhat.com> <1269340078-16446-3-git-send-email-armbru@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/4] monitor: New argument type 'b' List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On Tue, 23 Mar 2010 11:27:56 +0100 Markus Armbruster wrote: > 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..47b68a2 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 (!strncmp(beg, "on", p - beg)) { > + val = 1; > + } else if (!strncmp(beg, "off", p - beg)) { > + val = 0; > + } else { > + monitor_printf(mon, "Expected 'on' or 'off'\n"); > + goto fail; > + } This will make 'on' be the default when no on/off is specified, is that your intention? I'm wondering if this can cause problems when you add optional support for it and mixes it with other arguments. > + 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) {