From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNhY1-0001LZ-TG for qemu-devel@nongnu.org; Thu, 14 Jul 2016 10:23:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNhXy-0002rp-Lf for qemu-devel@nongnu.org; Thu, 14 Jul 2016 10:23:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNhXy-0002rd-Di for qemu-devel@nongnu.org; Thu, 14 Jul 2016 10:23:26 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFA2575F09 for ; Thu, 14 Jul 2016 14:23:25 +0000 (UTC) References: <1468505770-20694-1-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <5787A056.5090705@redhat.com> Date: Thu, 14 Jul 2016 08:23:18 -0600 MIME-Version: 1.0 In-Reply-To: <1468505770-20694-1-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QvCubMpginrEMGdcUsp3I5fqSUimxpEIV" Subject: Re: [Qemu-devel] [PATCH] qmp: add support for mixed typed input visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QvCubMpginrEMGdcUsp3I5fqSUimxpEIV From: Eric Blake To: "Daniel P. Berrange" , qemu-devel@nongnu.org Message-ID: <5787A056.5090705@redhat.com> Subject: Re: [PATCH] qmp: add support for mixed typed input visitor References: <1468505770-20694-1-git-send-email-berrange@redhat.com> In-Reply-To: <1468505770-20694-1-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/14/2016 08:16 AM, Daniel P. Berrange wrote: > Add a qmp_mixed_input_visitor_new() method which returns > a QMP input visitor that accepts either strings or the > native data types. >=20 > Signed-off-by: Daniel P. Berrange > --- >=20 > NB, just a demo - this should have tests added before submitting > for real. >=20 > =20 > +static void qmp_input_type_int64_mixed(Visitor *v, const char *name, i= nt64_t *obj, > + Error **errp) > +{ > + QmpInputVisitor *qiv =3D to_qiv(v); > + QObject *qobj =3D qmp_input_get_object(qiv, name, true); This consumes the key out of the QDict input stream... > + > + if (qobj && qobj->type =3D=3D QTYPE_QSTRING) { > + qmp_input_type_int64_str(v, name, obj, errp); then calls a helper function that also wants to consume the key. You'll have to use qmp_input_get_object(,false) for this to work (in other words, do a peek instead of consume when deciding which other helper to use). > + > +Visitor *qmp_mixed_input_visitor_new(QObject *obj, bool strict) > +{ I guess it's not too hard to generate 'qmp_mixed_input_visitor_new' instead of 'qmp_input_visitor_new' when 'autocast':true is set in QAPI, so that's a minor tweak to my series. Your version also has the benefit of not changing all existing callers to add another parameter. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --QvCubMpginrEMGdcUsp3I5fqSUimxpEIV 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/ iQEcBAEBCAAGBQJXh6BWAAoJEKeha0olJ0NqFHAH/0nDpOqvPuXI5DR6A7TwTSXr fbSBIO5oWQrQbSP6mu61kfrUBxI4iZ0W30q9m7p1l1g1+zHR4TChME+Be8TrP/fx 1c2zG3m+DP+n7p7RQGZ/9oxQdcovQ4Tx4cDXMlYvZMGfIwSX2TyEDXMWCvliCqju +uupPhRz03YpxzUBnBTathVIAKOybUezt88jV81wNnQeptkACzHIkxUQ3ls5jw+V Wabqw0BNlY1VhnpKziBPR623CTnSpWwGdn6kiWQVs6ST0YqLooDU0TjEpZH7mvOB WPGFJTTJl1tXE8uFcisdM+qm7hyJ0sjC1vsPmdzU4txRsel2y3cPTiWK9ptTjrU= =XwAw -----END PGP SIGNATURE----- --QvCubMpginrEMGdcUsp3I5fqSUimxpEIV--