From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQm2p-0002KY-83 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 19:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQm2k-0003hm-CK for qemu-devel@nongnu.org; Thu, 20 Mar 2014 19:06:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQm2k-0003hh-3o for qemu-devel@nongnu.org; Thu, 20 Mar 2014 19:06:34 -0400 Message-ID: <532B7475.2060502@redhat.com> Date: Thu, 20 Mar 2014 17:06:29 -0600 From: Eric Blake MIME-Version: 1.0 References: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com> <1395206201-22999-4-git-send-email-wenchaoqemu@gmail.com> In-Reply-To: <1395206201-22999-4-git-send-email-wenchaoqemu@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MuNSLcQ4FkWBgTCAWT5RQ3SAO5ThU0Lxg" Subject: Re: [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MuNSLcQ4FkWBgTCAWT5RQ3SAO5ThU0Lxg Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/18/2014 11:16 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". >=20 > The script mainly include two parts: generate API for each event s/include/includes/ > define, generate an enum type for all defined events. >=20 > Since in some case the real emit behavior may change, for example, s/case/cases/ > qemu-img would not send a event, a callback layer is used 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 +- > docs/qapi-code-gen.txt | 18 +++ > scripts/qapi-event.py | 373 ++++++++++++++++++++++++++++++++++++++++= ++++++++ > 4 files changed, 398 insertions(+), 4 deletions(-) > create mode 100644 scripts/qapi-event.py >=20 > +++ b/docs/qapi-code-gen.txt > @@ -180,6 +180,24 @@ An example command is: > 'data': { 'arg1': 'str', '*arg2': 'str' }, > 'returns': 'str' } > =20 > +=3D=3D=3D Events =3D=3D=3D > + > +Events are defined with key workd 'event'. When 'data' is also specif= ied, s/workd/word/ > +additional info will be carried on. Finally there will be C API gener= ated > +in qapi-event.h, and when called by QEMU code, message with timestamp = will s/message/a message/ > +be emit on the wire. If timestamp is -1, it means failure in host tim= e s/emit/emitted/ > +retrieving. s/in host time retrieving/to retrieve host time/ > +++ b/scripts/qapi-event.py > @@ -0,0 +1,373 @@ > +# > +# QAPI event generator > +# > +# Authors: > +# Wenchao Xia > +# > +# This work is licensed under the terms of the GNU GPL, version 2. > +# See the COPYING file in the top-level directory. Needs to use "Copyright". > + > + if params: > + for argname, argentry, optional, structured in parse_args(para= ms): > + if structured: > + sys.stderr.write("Nested structure define in event is = not " > + "supported now, event '%s', argname '= %s'\n" % > + (event_name, argname)) > + sys.exit(1) > + continue Isn't this 'continue' dead code? > + > +# Following are the functions that generate an enum type for all defin= ed > +# events, similar with qapi-types.py. Here we already have enum name a= nd s/with/to/ > +# values which is generated before and recorded in event_enum_*. It al= so s/is/were/ > +# walk around the issue that "import qapi-types" can't work. s/walk around/works around/ > + > +fdef.write(mcgen(''' > +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ > + > +/* > + * schema-defined QAPI event functions > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU LGPL, version 2.1 = or later. > + * See the COPYING.LIB file in the top-level directory. Also needs "Copyright" > +fdecl.write(mcgen(''' > +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ > + > +/* > + * schema-defined QAPI event function s/function/functions/ > + * > + * Authors: > + * Wenchao Xia > + * > + * This work is licensed under the terms of the GNU LGPL, version 2.1 = or later. > + * See the COPYING.LIB file in the top-level directory. Needs "Copyright" --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --MuNSLcQ4FkWBgTCAWT5RQ3SAO5ThU0Lxg 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/ iQEcBAEBCAAGBQJTK3R1AAoJEKeha0olJ0NqdckH/R31ms93qnisQJ97cPrQQzLT hEAFTQWduZZXikMWLdTOt1yGzGn41TQDL/COlWih6dOIMN0QF24cN8lQxFmHnsRU bWLr5xt4DcMVW2y0wxAQA8EearC46z0I2Ch2VmGUctJJ6yUiDZ52EbV4MoB+yxS6 OxI/Qr6f5UmGFhXNDnrNINTezrf0HiOsXxJhT1b98C8NP86QV0yx2iQftEV1gUy1 GKtm1IgK1slvbothsay+cr3yXWREDNfNyCFNL5EPwNgVVLQtkp7fQyKvl2Njxwwn Yxeg5R36kVDeAHzvocDQ0KsevT8dh16w/b7DW+7H8f8FVG8FSCUXZHcxccC+4f0= =3pSh -----END PGP SIGNATURE----- --MuNSLcQ4FkWBgTCAWT5RQ3SAO5ThU0Lxg--