qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_inpu


From: Igor Mammedov
Subject: Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor
Date: Mon, 25 Nov 2013 16:36:42 +0100

On Thu, 21 Nov 2013 11:15:06 +0100
Markus Armbruster <address@hidden> wrote:

> Igor Mammedov <address@hidden> writes:
> 
> > Signed-off-by: Igor Mammedov <address@hidden>
> > ---
> >  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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]