From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkUvO-00081M-VK for qemu-devel@nongnu.org; Thu, 15 Sep 2016 07:33:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkUvJ-0002Hk-A3 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 07:33:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkUvJ-0002HF-0I for qemu-devel@nongnu.org; Thu, 15 Sep 2016 07:33:45 -0400 Date: Thu, 15 Sep 2016 12:33:41 +0100 From: "Daniel P. Berrange" Message-ID: <20160915113340.GI26068@redhat.com> Reply-To: "Daniel P. Berrange" References: <1473088600-17930-1-git-send-email-berrange@redhat.com> <1473088600-17930-6-git-send-email-berrange@redhat.com> <20160914145950.GF4649@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160914145950.GF4649@noname.redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v11 5/6] qapi: add a QmpInputVisitor that does string conversion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, Markus Armbruster , Max Reitz , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Andreas =?utf-8?Q?F=C3=A4rber?= 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. > >=20 > > This adds an alternative constructor for QmpInputVisitor > > that will set it up such that it expects a QString for > > all scalar types instead. > >=20 > > This makes it possible to use QmpInputVisitor with a > > QDict produced from QemuOpts, where everything is in > > string format. > >=20 > > Reviewed-by: Marc-Andr=C3=A9 Lureau > > Signed-off-by: Daniel P. Berrange >=20 > > +static void qobject_input_type_size_str(Visitor *v, const char *name= , > > + uint64_t *obj, Error **errp) > > +{ > > + QObjectInputVisitor *qiv =3D to_qiv(v); > > + QString *qstr =3D qobject_to_qstring(qobject_input_get_object(qi= v, name, > > + true= )); > > + int64_t val; > > + char *endptr; > > + > > + if (qstr && qstr->string) { > > + val =3D 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 =3D val; > > + return; > > + } > > + > > + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "nul= l", > > + "size"); > > +} >=20 > 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 --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|