[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does s
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion |
Date: |
Thu, 15 Sep 2016 12:33:41 +0100 |
User-agent: |
Mutt/1.7.0 (2016-08-17) |
On Wed, Sep 14, 2016 at 04:59:50PM +0200, Kevin Wolf wrote:
> Am 05.09.2016 um 17:16 hat Daniel P. Berrange geschrieben:
> > Currently the QmpInputVisitor assumes that all scalar
> > values are directly represented as their final types.
> > ie it assumes an 'int' is using QInt, and a 'bool' is
> > using QBool.
> >
> > This adds an alternative constructor for QmpInputVisitor
> > that will set it up such that it expects a QString for
> > all scalar types instead.
> >
> > This makes it possible to use QmpInputVisitor with a
> > QDict produced from QemuOpts, where everything is in
> > string format.
> >
> > Reviewed-by: Marc-André Lureau <address@hidden>
> > Signed-off-by: Daniel P. Berrange <address@hidden>
>
> > +static void qobject_input_type_size_str(Visitor *v, const char *name,
> > + uint64_t *obj, Error **errp)
> > +{
> > + QObjectInputVisitor *qiv = to_qiv(v);
> > + QString *qstr = qobject_to_qstring(qobject_input_get_object(qiv, name,
> > + true));
> > + int64_t val;
> > + char *endptr;
> > +
> > + if (qstr && qstr->string) {
> > + val = qemu_strtosz_suffix(qstr->string, &endptr,
> > + QEMU_STRTOSZ_DEFSUFFIX_B);
> > + if (val < 0 || *endptr) {
> > + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
> > + "a size value representible as a non-negative
> > int64");
> > + return;
> > + }
> > +
> > + *obj = val;
> > + return;
> > + }
> > +
> > + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> > + "size");
> > +}
>
> Why not use parse_option_size() here when you use the QemuOpts parser
> for the other functions?
No idea why i didn't use that.
> Of course, parse_option_size() could be switched to internally use
> qemu_strtosz_suffix() sooner or later, too, but that's a different
> problem...
Yes, it really should. I might just do that later.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion, Kevin Wolf, 2016/09/14
- Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion,
Daniel P. Berrange <=
[Qemu-devel] [PATCH v11 3/6] qapi: rename QmpInputVisitor to QObjectInputVisitor, Daniel P. Berrange, 2016/09/05
[Qemu-devel] [PATCH v11 4/6] qapi: rename QmpOutputVisitor to QObjectOutputVisitor, Daniel P. Berrange, 2016/09/05
[Qemu-devel] [PATCH v11 6/6] qom: support arbitrary non-scalar properties with -object, Daniel P. Berrange, 2016/09/05