On Mon, Nov 25, 2013 at 04:36:42PM +0100, Igor Mammedov wrote: > On Thu, 21 Nov 2013 11:15:06 +0100 > Markus Armbruster <arm...@redhat.com> wrote: > > > Igor Mammedov <imamm...@redhat.com> writes: > > > > > Signed-off-by: Igor Mammedov <imamm...@redhat.com> > > > --- > > > 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