From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkyb6-0001iP-Qt for qemu-devel@nongnu.org; Mon, 25 Nov 2013 11:01:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vkyay-0002SX-V3 for qemu-devel@nongnu.org; Mon, 25 Nov 2013 11:01:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkyay-0002S8-Mo for qemu-devel@nongnu.org; Mon, 25 Nov 2013 11:01:08 -0500 Date: Mon, 25 Nov 2013 18:04:05 +0200 From: "Michael S. Tsirkin" Message-ID: <20131125160337.GB10326@redhat.com> References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> <1385001528-12003-6-git-send-email-imammedo@redhat.com> <87r4aaxdqt.fsf@blackfin.pond.sub.org> <20131125163642.4d832fd5@nial.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131125163642.4d832fd5@nial.usersys.redhat.com> Subject: Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: peter.maydell@linaro.org, mdroth@linux.vnet.ibm.com, stefanb@linux.vnet.ibm.com, hutao@cn.fujitsu.com, quintela@redhat.com, mjt@tls.msk.ru, Markus Armbruster , qemu-devel@nongnu.org, vasilis.liaskovitis@profitbricks.com, chegu_vinod@hp.com, kraxel@redhat.com, aliguori@amazon.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, afaerber@suse.de On Mon, Nov 25, 2013 at 04:36:42PM +0100, Igor Mammedov wrote: > On Thu, 21 Nov 2013 11:15:06 +0100 > Markus Armbruster wrote: > > > Igor Mammedov writes: > > > > > Signed-off-by: Igor Mammedov > > > --- > > > qapi/string-input-visitor.c | 18 ++++++++++++++++++ > > > 1 files changed, 18 insertions(+), 0 deletions(-) > > > > > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c > > > index 8f1bc41..a152f5d 100644 > > > --- a/qapi/string-input-visitor.c > > > +++ b/qapi/string-input-visitor.c > > > @@ -97,6 +97,23 @@ static void parse_type_number(Visitor *v, double *obj, const char *name, > > > *obj = val; > > > } > > > > > > +static void parse_type_size(Visitor *v, uint64_t *obj, const char *name, > > > + Error **errp) > > > +{ > > > + StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v); > > > + int64_t val; > > > + char *endp; > > > + > > > + val = strtosz_suffix(siv->string ? siv->string : "", &endp, > > > + STRTOSZ_DEFSUFFIX_B); > > > + if (val < 0 || *endp != '\0') { > > > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, > > > + "a size value representible as a non-negative int64"); > > > + return; > > > + } > > > + *obj = val; > > > +} > > > + > > > static void parse_start_optional(Visitor *v, bool *present, > > > const char *name, Error **errp) > > > { > > > @@ -131,6 +148,7 @@ StringInputVisitor *string_input_visitor_new(const char *str) > > > v->visitor.type_bool = parse_type_bool; > > > v->visitor.type_str = parse_type_str; > > > v->visitor.type_number = parse_type_number; > > > + v->visitor.type_size = parse_type_size; > > > v->visitor.start_optional = parse_start_optional; > > > > > > v->string = str; > > > > Does this put syntax like "value": "128M" in QMP? If yes, NAK. QMP > > does not want fancy syntax for numbers, only plain numbers. > > > > I thought QMP uses its own qmp_visitor, so it shouldn't affect general QMP, > if I'm not mistaken. > > but it allows to use unified memdev_add parser for all interfaces (CLI/HMP/QMP) and > it's more user friendly to have on CLI/HMP size=1G vs long integer to express it. Yes please. Firing up a calculator to figure out how much is 1G is not friendly, neither is firing it up to figure out what did management do with QMP. It should be a text based interface not a binary one. -- MST