From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8sG5-0006Tu-Hi for qemu-devel@nongnu.org; Mon, 21 Nov 2016 12:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8sG2-00043I-7Y for qemu-devel@nongnu.org; Mon, 21 Nov 2016 12:19:57 -0500 Received: from mo53.mail-out.ovh.net ([178.32.228.53]:44072) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c8sG2-000437-0I for qemu-devel@nongnu.org; Mon, 21 Nov 2016 12:19:54 -0500 Received: from player158.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo53.mail-out.ovh.net (Postfix) with ESMTP id 28DF242B70 for ; Mon, 21 Nov 2016 18:19:52 +0100 (CET) Date: Mon, 21 Nov 2016 18:19:45 +0100 From: Greg Kurz Message-ID: <20161121181945.33318e30@bahia> In-Reply-To: <652a5dd2-a3d4-df78-9d49-243ef744ac90@redhat.com> References: <147954362297.28064.5118492606031513925.stgit@bahia> <652a5dd2-a3d4-df78-9d49-243ef744ac90@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/=T6tGK0H=5UQ0YaAk_5QtYB"; protocol="application/pgp-signature" Subject: Re: [Qemu-devel] [PATCH] qapi: add explicit null to string input and output visitors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth , Markus Armbruster , David Gibson --Sig_/=T6tGK0H=5UQ0YaAk_5QtYB Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 21 Nov 2016 10:32:50 -0600 Eric Blake wrote: > On 11/19/2016 02:28 AM, Greg Kurz wrote: > > This may be used for deprecated object properties that are kept for > > backwards compatibility. > >=20 > > Signed-off-by: Greg Kurz > > --- > >=20 > > This is enough to fix David's patch: > >=20 > > [RFCv2 10/12] pseries: Move CPU compatibility property to machine =20 >=20 > Do we need both input and output visitors, or is the problem only caused > on an output visit? >=20 David's patch unifies the get/set property info callbacks into a single getset_compat_deprecated() function which calls visit_type_null(). So, even if the operation is a nop for input visitors, we need it anyway, otherwise visit_type_null() dereferences a NULL pointer. > >=20 > > Messag-Id: <1479248275-18889-11-git-send-email-david@gibson.dropbear.id= .au> > >=20 > > qapi/string-input-visitor.c | 5 +++++ > > qapi/string-output-visitor.c | 14 ++++++++++++++ > > 2 files changed, 19 insertions(+) > >=20 > > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c > > index 8dfa5612522b..4a378d7b67e6 100644 > > --- a/qapi/string-input-visitor.c > > +++ b/qapi/string-input-visitor.c > > @@ -314,6 +314,10 @@ static void parse_type_number(Visitor *v, const ch= ar *name, double *obj, > > *obj =3D val; > > } > > =20 > > +static void parse_type_null(Visitor *v, const char *name, Error **errp) > > +{ > > +} =20 >=20 > In particular, this always succeeds, even though we don't have a > symmetric way to guarantee that the user can specifically request NULL > input (the qobject visitor checks for the JSON keyword NULL, but that's > different from string parsing), so I'm a bit worried that it is not > doing what we want. If you omit this hunk, does the problem with David's > patch still go away with just the output visitor change? >=20 What we want here is to simply ignore any string the user would pass. As explained above, this hunk is needed as long as David's patch calls visit_type_null() for both input and output. Otherwise, it should have separate functions: get_compat_deprecated() which calls visit_type_null() and set_compat_deprecated() which does nothing. > > + > > static void parse_optional(Visitor *v, const char *name, bool *present) > > { > > StringInputVisitor *siv =3D to_siv(v); > > @@ -348,6 +352,7 @@ Visitor *string_input_visitor_new(const char *str) > > v->visitor.type_bool =3D parse_type_bool; > > v->visitor.type_str =3D parse_type_str; > > v->visitor.type_number =3D parse_type_number; > > + v->visitor.type_null =3D parse_type_null; > > v->visitor.start_list =3D start_list; > > v->visitor.next_list =3D next_list; > > v->visitor.end_list =3D end_list; > > diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c > > index 94ac8211d144..5ec5352ca87c 100644 > > --- a/qapi/string-output-visitor.c > > +++ b/qapi/string-output-visitor.c > > @@ -266,6 +266,19 @@ static void print_type_number(Visitor *v, const ch= ar *name, double *obj, > > string_output_set(sov, g_strdup_printf("%f", *obj)); > > } > > =20 > > +static void print_type_null(Visitor *v, const char *name, Error **errp) > > +{ > > + StringOutputVisitor *sov =3D to_sov(v); > > + char *out; > > + > > + if (sov->human) { > > + out =3D g_strdup(""); > > + } else { > > + out =3D g_strdup(""); > > + } > > + string_output_set(sov, out); > > +} > > + > > static void > > start_list(Visitor *v, const char *name, GenericList **list, size_t si= ze, > > Error **errp) > > @@ -351,6 +364,7 @@ Visitor *string_output_visitor_new(bool human, char= **result) > > v->visitor.type_bool =3D print_type_bool; > > v->visitor.type_str =3D print_type_str; > > v->visitor.type_number =3D print_type_number; > > + v->visitor.type_null =3D print_type_null; > > v->visitor.start_list =3D start_list; > > v->visitor.next_list =3D next_list; > > v->visitor.end_list =3D end_list; > >=20 > >=20 > > =20 >=20 --Sig_/=T6tGK0H=5UQ0YaAk_5QtYB Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlgzLLEACgkQAvw66wEB28JknQCfdvEZKqsM1i0BtBMyqJgdn3rG hOAAn1eUKmBqO2mU4eow95PPR+kxptsE =XjG5 -----END PGP SIGNATURE----- --Sig_/=T6tGK0H=5UQ0YaAk_5QtYB--