From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBfJ-0003Of-Ta for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:59:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkBfF-00072g-H8 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:59:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBfF-00072N-BE for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:59:53 -0400 Date: Wed, 14 Sep 2016 16:59:50 +0200 From: Kevin Wolf Message-ID: <20160914145950.GF4649@noname.redhat.com> References: <1473088600-17930-1-git-send-email-berrange@redhat.com> <1473088600-17930-6-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1473088600-17930-6-git-send-email-berrange@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: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Markus Armbruster , Max Reitz , =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , Paolo Bonzini , Andreas =?iso-8859-1?Q?F=E4rber?= 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=E9 Lureau > Signed-off-by: Daniel P. Berrange > +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(qiv,= 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 i= nt64"); > + return; > + } > + > + *obj =3D 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? Of course, parse_option_size() could be switched to internally use qemu_strtosz_suffix() sooner or later, too, but that's a different problem... Kevin