From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNfz8-0000PX-4X for qemu-devel@nongnu.org; Thu, 14 Jul 2016 08:43:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNfz3-00054b-Vp for qemu-devel@nongnu.org; Thu, 14 Jul 2016 08:43:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNfz3-00054I-NI for qemu-devel@nongnu.org; Thu, 14 Jul 2016 08:43:17 -0400 References: <1468468228-27827-1-git-send-email-eblake@redhat.com> <1468468228-27827-17-git-send-email-eblake@redhat.com> <20160714080423.GB18778@redhat.com> From: Eric Blake Message-ID: <578788E4.9020205@redhat.com> Date: Thu, 14 Jul 2016 06:43:16 -0600 MIME-Version: 1.0 In-Reply-To: <20160714080423.GB18778@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UtVgnOc8voi5loEJmgna39QxtwN5t3Bp3" Subject: Re: [Qemu-devel] [PATCH v9 16/17] qapi: Tweak QmpInputVisitor to optionally do string conversion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, armbru@redhat.com, Michael Roth , =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UtVgnOc8voi5loEJmgna39QxtwN5t3Bp3 From: Eric Blake To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, armbru@redhat.com, Michael Roth , =?UTF-8?Q?Andreas_F=c3=a4rber?= Message-ID: <578788E4.9020205@redhat.com> Subject: Re: [PATCH v9 16/17] qapi: Tweak QmpInputVisitor to optionally do string conversion References: <1468468228-27827-1-git-send-email-eblake@redhat.com> <1468468228-27827-17-git-send-email-eblake@redhat.com> <20160714080423.GB18778@redhat.com> In-Reply-To: <20160714080423.GB18778@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/14/2016 02:04 AM, Daniel P. Berrange wrote: > On Wed, Jul 13, 2016 at 09:50:27PM -0600, Eric Blake wrote: >> 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 mode where a QString can also >> be parsed in place of the native type, by adding a parameter >> and updating all callers. For now, only the testsuite sets >> the new autocast parameter. >> >> This makes it possible to use QmpInputVisitor with a QDict >> produced from QemuOpts, where everything is in string format. >> It also makes it possible for the next patch to support >> back-compat in legacy commands like 'netdev_add' that no >> longer use QemuOpts, but must parse the same set of QMP >> constructs that QemuOpts would historically allow. >=20 > I'm not really a huge fan of the approach there. IMHO the > input visitor should strictly operate in "all native types" > or "all string types" mode. The way you've done it here > means that users can actually mix & match strings vs native > types for each individual parameter :-( >=20 > IMHO, I'd suggest you try to parse netdev_add args with > it in "all native types" mode, if that fails, then re-parse > in "all string types" mode. Sadly, this idea won't work. Without this series, the existing QMP command 'netdev_add' takes mixed integers and strings in a single call, by virtue of converting QObject into QemuOpts and back into QObject. Forcing the parser to allow only integers or only strings would reject current uses of netdev_add, and we don't yet have a good idea whether any existing clients were depending on that behavior. Also, see patch 17/17 - the easiest way to implement a relaxed QMP parse is by setting a single flag which controls which visitor constructor is used. Your idea of parsing once with integer-only, then falling back to parse a second time with string-only, would complicate the generator to have to create two different visitors, rather than passing a single boolean parameter through to the single visitor constructor. >=20 > For that you'd not have to modify my patch at all. >=20 Also not quite true - your patch no longer applies to master, so it needed rebasing anyway. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --UtVgnOc8voi5loEJmgna39QxtwN5t3Bp3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXh4jkAAoJEKeha0olJ0NqgGAH/2raDyxz0IzBqzeOICWgYc21 PSejIcxVxTJH1ZTwISMkx/UFWXEWgIPmPB0Q/+I3rf7toj/IBwBnII6FujvgUxmK EgtuMhrQ8FgxymEBpwhEQ2wVxDDo+r45Oqdd0+lva77urYTSNGP1R0Bz6Jeur6jy JQR9IIlp7ytCWA/twuZ08xKm9m8h9G8CqkBMHjMxL4xktrb0bNmLgDd2ejRhUAiG T3RxDzt73KArZto4HuN0aDL+vAu8BC1iXY81Z0ccuCjwkW8ZqD6qa/lElpLnEjDL oViJKmsXI9mWpp4Xe6lPtTWCB5h48Wckqc+497hgeTMrtYj8rdzzo5M58LG9dVo= =Ojoo -----END PGP SIGNATURE----- --UtVgnOc8voi5loEJmgna39QxtwN5t3Bp3--