From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQ6Og-0005Pb-UJ for qemu-devel@nongnu.org; Tue, 18 Mar 2014 22:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQ6Oa-0006un-M3 for qemu-devel@nongnu.org; Tue, 18 Mar 2014 22:38:26 -0400 Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:32969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQ6Oa-0006ui-Dj for qemu-devel@nongnu.org; Tue, 18 Mar 2014 22:38:20 -0400 Received: by mail-pd0-f170.google.com with SMTP id v10so8041975pde.1 for ; Tue, 18 Mar 2014 19:38:19 -0700 (PDT) Message-ID: <5329030F.5010401@gmail.com> Date: Wed, 19 Mar 2014 10:38:07 +0800 From: Wenchao Xia 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> <5318C354.6060706@redhat.com> In-Reply-To: <5318C354.6060706@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: Eric Blake Cc: armbru@redhat.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 于 2014/3/7 2:49, Eric Blake 写道: > 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. >> >> 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. >> >> 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. >> >> 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 = getopt.gnu_getopt(sys.argv[1:], "chbp:o:", >> + ["source", "header", "builtins", "prefix=", >> + "output-dir="]) >> +except getopt.GetoptError, err: >> + print str(err) >> + sys.exit(1) >> + >> +output_dir = "" >> +prefix = "" >> +c_file = 'qapi-event.c' >> +h_file = 'qapi-event.h' >> + >> +do_c = False >> +do_h = False >> +do_builtins = False >> + >> +for o, a in opts: >> + if o in ("-p", "--prefix"): >> + prefix = a >> + elif o in ("-o", "--output-dir"): >> + output_dir = a + "/" >> + elif o in ("-c", "--source"): >> + do_c = True >> + elif o in ("-h", "--header"): >> + do_h = True >> + elif o in ("-b", "--builtins"): >> + do_builtins = 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. It seems qapi-visit.py and qapi-types.py remains the same as above in upstream, which kind of change are your referring to? >> +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). >