From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLdea-0000kU-CA for qemu-devel@nongnu.org; Thu, 06 Mar 2014 14:08:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLdeV-00044C-Fz for qemu-devel@nongnu.org; Thu, 06 Mar 2014 14:08:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLdeV-00043r-6m for qemu-devel@nongnu.org; Thu, 06 Mar 2014 14:08:19 -0500 Message-ID: <5318C354.6060706@redhat.com> Date: Thu, 06 Mar 2014 11:49:56 -0700 From: Eric Blake MIME-Version: 1.0 References: <1388704234-22498-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1388704234-22498-4-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1388704234-22498-4-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aPGIP9oC8muXatfaT5DUvvgxgnaNNMQqB" Subject: Re: [Qemu-devel] [RFC PATCH V2 3/5] qapi script: add event support by qapi-event.py List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: mreitz@redhat.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aPGIP9oC8muXatfaT5DUvvgxgnaNNMQqB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/02/2014 04:10 PM, Wenchao Xia wrote: > qapi-event.py will parse the schema and generate qapi-event.c, then > the API in qapi-event.c can be used to handle event in qemu code. > All API have prefix "qapi_event", all types have prefix "QAPIEvent". > Examples can be found in following patches. >=20 > The script mainly include three parts: generate API for each event > define, generate an enum type for all defined event, generate behavior s/event/events/ > control functions. >=20 > Since in some case the real emit behavior may change, for example, > qemu-img would not send a event, a callback layer is added to > control the behavior. As a result, the stubs at compile time > can be saved, the binding of block layer code and monitor code > will become looser. >=20 > Signed-off-by: Wenchao Xia > --- > Makefile | 9 +- > Makefile.objs | 2 +- > scripts/qapi-event.py | 432 +++++++++++++++++++++++++++++++++++++++++= ++++++++ > 3 files changed, 439 insertions(+), 4 deletions(-) > create mode 100644 scripts/qapi-event.py In addition to Luiz' comments, you are missing documentation. At a minimum, docs/qapi-code-gen.txt should be updated. > +try: > + opts, args =3D getopt.gnu_getopt(sys.argv[1:], "chbp:o:", > + ["source", "header", "builtins", "p= refix=3D", > + "output-dir=3D"]) > +except getopt.GetoptError, err: > + print str(err) > + sys.exit(1) > + > +output_dir =3D "" > +prefix =3D "" > +c_file =3D 'qapi-event.c' > +h_file =3D 'qapi-event.h' > + > +do_c =3D False > +do_h =3D False > +do_builtins =3D False > + > +for o, a in opts: > + if o in ("-p", "--prefix"): > + prefix =3D a > + elif o in ("-o", "--output-dir"): > + output_dir =3D a + "/" > + elif o in ("-c", "--source"): > + do_c =3D True > + elif o in ("-h", "--header"): > + do_h =3D True > + elif o in ("-b", "--builtins"): > + do_builtins =3D True You may need to rebase this on top of other patches that refactor the qapi generators to track the input file, for improved error messages. > +fdef.write(mcgen(''' > +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ > + > +/* > + * schema-defined QAPI event functions > + * > + * Copyright IBM, Corp. 2014 > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU GPLv2+ or later. > + * See the COPYING.LIB file in the top-level directory. Fix this. If these are really GPL files, then they should refer to COPYING. If you meant LGPL for the generated files, say so (but that's possibly at odds with other parts of your patch that put the generator under GPL). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --aPGIP9oC8muXatfaT5DUvvgxgnaNNMQqB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTGMNUAAoJEKeha0olJ0Nq2K4H/ROg8TgHVDsT8NKs3oiDNHDZ c9E7dUAofs7cX+ABHm6fsYga7Ek4TfcgGmvuaVUVkMe/1EuybtKeUCaNf70nY1gj 35u3Zbhq9UgVU06W8mV2/y+lo85Btl27aYt+FMg4zdFKd+Dtpp9e+SdNtXTzF4Wg 0fD2Dm7JOprV2EFbVqi7V89kHVZJe27uECHRAC/Faf7F1GdBzIYs989cI+xLISjP uTIiXjfSG0mzr/iSFQRC/kb8osrD2oa2DSTck4byCUxs26pXItKeE2811UJ/z84b N6f7qXjoe3vkfnkTKiTJ59+2nqGrGW9qaBOLvp1HEPpgv1L4KLhKXdcXKxGU4yg= =x8IB -----END PGP SIGNATURE----- --aPGIP9oC8muXatfaT5DUvvgxgnaNNMQqB--