[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support |
Date: |
Thu, 20 Mar 2014 17:06:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
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 <address@hidden>
> ---
> 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 <address@hidden>
> +#
> +# 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 <address@hidden>
> + *
> + * 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 <address@hidden>
> + *
> + * 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
- [Qemu-devel] [RFC PATCH V3 0/5] add direct support of event in qapi schema, Wenchao Xia, 2014/03/19
- [Qemu-devel] [RFC PATCH V3 1/5] os-posix: include sys/time.h, Wenchao Xia, 2014/03/19
- [Qemu-devel] [RFC PATCH V3 2/5] qapi: add event helper functions, Wenchao Xia, 2014/03/19
- [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support, Wenchao Xia, 2014/03/19
- Re: [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support,
Eric Blake <=
- [Qemu-devel] [RFC PATCH V3 4/5] test: add test cases for qapi event, Wenchao Xia, 2014/03/19
- [Qemu-devel] [RFC PATCH V3 5/5] qapi event: convert RTC_CHANGE, Wenchao Xia, 2014/03/19