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". > > The script mainly include two parts: generate API for each event
s/include/includes/ > define, generate an enum type for all defined events. > > 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. > > Signed-off-by: Wenchao Xia <wenchaoq...@gmail.com> > --- > 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 > > +++ b/docs/qapi-code-gen.txt > @@ -180,6 +180,24 @@ An example command is: > 'data': { 'arg1': 'str', '*arg2': 'str' }, > 'returns': 'str' } > > +=== Events === > + > +Events are defined with key workd 'event'. When 'data' is also specified, s/workd/word/ > +additional info will be carried on. Finally there will be C API generated > +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 time 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 <wenchaoq...@gmail.com> > +# > +# 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(params): > + 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 defined > +# events, similar with qapi-types.py. Here we already have enum name and s/with/to/ > +# values which is generated before and recorded in event_enum_*. It also 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 <wenchaoq...@gmail.com> > + * > + * 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 <wenchaoq...@gmail.com> > + * > + * 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" -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature