From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axyZ6-0006b4-76 for qemu-devel@nongnu.org; Wed, 04 May 2016 11:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axyYu-0007i7-Cp for qemu-devel@nongnu.org; Wed, 04 May 2016 11:18:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axyYu-0007d8-6Y for qemu-devel@nongnu.org; Wed, 04 May 2016 11:18:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 2A13D80F74 for ; Wed, 4 May 2016 15:17:53 +0000 (UTC) References: <20160503094447.GE2242@work-vm> <87inyv5nv7.fsf@dusky.pond.sub.org> <20160503132358.GH2242@work-vm> <87eg9iyypp.fsf@dusky.pond.sub.org> <20160504092249.GC2302@work-vm> <87lh3qrr4a.fsf@dusky.pond.sub.org> <20160504115616.GE2302@work-vm> <87pot2ou5r.fsf@dusky.pond.sub.org> <20160504131905.GH2302@work-vm> <87shxxnccm.fsf@dusky.pond.sub.org> <20160504145358.GI2302@work-vm> From: Eric Blake Message-ID: <572A129F.7020702@redhat.com> Date: Wed, 4 May 2016 09:17:51 -0600 MIME-Version: 1.0 In-Reply-To: <20160504145358.GI2302@work-vm> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r7mGIdnrGn35ciTfr5AtLtj58cfBT0S3l" Subject: Re: [Qemu-devel] [PATCH v3 10/18] vmstate: Use new JSON output visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" , Markus Armbruster Cc: Amit Shah , famz@redhat.com, qemu-devel@nongnu.org, Juan Quintela This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r7mGIdnrGn35ciTfr5AtLtj58cfBT0S3l Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/04/2016 08:53 AM, Dr. David Alan Gilbert wrote: >> Here's the example from visitor.h at the end of this series (with a >> small mistake corrected): >> >> Visitor *v; >> Error *err =3D NULL; >> int value; >> >> v =3D ...obtain visitor... >> visit_start_struct(v, NULL, NULL, 0, &err); >> if (err) { >> goto out; >> } >> visit_start_list(v, "list", NULL, 0, &err); >> if (err) { >> goto outobj; >> } >> value =3D 1; >> visit_type_int(v, NULL, &value, &err); >> if (err) { >> goto outlist; >> } >> value =3D 2; >> visit_type_int(v, NULL, &value, &err); >> if (err) { >> goto outlist; >> } >> outlist: >> visit_end_list(v, NULL); >> if (!err) { >> visit_check_struct(v, &err); >> } >> outobj: >> visit_end_struct(v, NULL); > Hmm the visit_end_* are interesting; I guess we have to be careful > of those, unless that is you could make the visit_end_struct(v, NULL) > to fail nicely in that case. Here, visit_end_struct() _can't_ fail; you are passing NULL to match the fact that the earlier visit_start_struct() passed NULL for obj (that is, at the end of the current qapi series, the parameter changes from Error** to void **, and is NOT an error indicator). >> >> Visitors will abort when their preconditions or invariants are violate= d. And it's very easy to avoid violating those preconditions. But if it's not easy enough for you, then the solution is... >> If that's not okay for migration, I'm afraid migration needs to contin= ue >> to roll its own JSON writer. Visitors are pretty heavily used nowaday= s, >> and we very much rely on these assertions to catch mistakes. >=20 > OK, lets keep our own writer; if we can't have more control over visito= rs > failure paths, we'll have to. =2E..exactly this. So in the next spin of my series, I will drop (both!) of my attempts to rework qjson.c to reuse the visitors, and instead just move it into the migration tree and out of the top level. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --r7mGIdnrGn35ciTfr5AtLtj58cfBT0S3l 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/ iQEcBAEBCAAGBQJXKhKfAAoJEKeha0olJ0NqiBUH/2cBgcvhnPE3+qrF63vNWlRQ pL8igcoyZdTPJnGbiD14cLbJgNktmPERJLXf7415PnsSkzpVLk0Yfni2p1wSjlbs sfsFg7M8QcmmLwo6KdmapvHfdrFIHdm3ZfoSNvIGiEB4AtTooqLHPKeesYl35PKP nwalDGt+b+1iwpOoUDSVD+k8GYxRcQ+/U7RJDJT9BFfJKk9yigoRS6wFnvMWwEvX MaZbaBfUj2nPT0yiGo718Kr71sgfpR0JTRwz1dVaGB6SjbhzSxhZB4cBbu8pEHh2 jVWxPl+KPTDUsYTIO55xoouO6ugEsHkgP2zsUm+5JOkObSFmfJAIuvcUfeevbl8= =jN6M -----END PGP SIGNATURE----- --r7mGIdnrGn35ciTfr5AtLtj58cfBT0S3l--