From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRtFU-0008QO-GP for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:00:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRtFO-0005Ei-Pm for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:00:20 -0400 Received: from mail-ob0-x22e.google.com ([2607:f8b0:4003:c01::22e]:46253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRtFO-0005Ee-JR for qemu-devel@nongnu.org; Sun, 23 Mar 2014 21:00:14 -0400 Received: by mail-ob0-f174.google.com with SMTP id wo20so4943490obc.5 for ; Sun, 23 Mar 2014 18:00:13 -0700 (PDT) Message-ID: <532F838C.9040409@gmail.com> Date: Mon, 24 Mar 2014 08:59:56 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1395206201-22999-1-git-send-email-wenchaoqemu@gmail.com> <1395206201-22999-4-git-send-email-wenchaoqemu@gmail.com> <532B7475.2060502@redhat.com> In-Reply-To: <532B7475.2060502@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: Eric Blake Cc: mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com 于 2014/3/21 7:06, Eric Blake 写道: > 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 >> --- >> 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 >> +# >> +# 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? Yes, I missed it. I'd like to respin a rfc v4, with better error check function moved into qapi.py, just like the series which check error for other kind of schema error. > >> + >> +# 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 >> + * >> + * 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" >