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 <marcandre.lur...@redhat.com> > > Signed-off-by: Daniel P. Berrange <berra...@redhat.com> > > > +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 :|