qemu-devel
[Top][All Lists]
Advanced

[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: Wenchao Xia
Subject: Re: [Qemu-devel] [RFC PATCH V3 3/5] qapi script: add event support
Date: Mon, 24 Mar 2014 08:59:56 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

于 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<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?
  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<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"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]