qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH V2 3/5] qapi script: add event support by qa


From: Wenchao Xia
Subject: Re: [Qemu-devel] [RFC PATCH V2 3/5] qapi script: add event support by qapi-event.py
Date: Fri, 14 Feb 2014 11:26:51 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

于 2014/1/7 11:24, Wenchao Xia 写道:
+
+
+# Following are the functions that generate event behavior control
functions.
+# Those functions are put here in the qapi-event.c, since it need
to include
+# qapi-event.h for the event enum type declaration, put them in
other file
+# requiring other file include qapi-event.h, causing a cross
including. For
+# example: if we have qmp-event.c and qmp-event.h, then qmp-event.c
+# ->qmp-event.h->qapi-event.h, qapi-event.c->qmp-event.h. Another
problem
+# follow: test-qapi-event.c will meet event enum double declaration
since it
+# include both test-qapi-event.h and qmp-event.h. One solution is
putting event
+# enum declaration in a separate header file, but then qmp-event.h
need to
+# include test-qapi-event.h or qapi-event.h on compile time
condition. So the
+# easist way is, just generate them here.
+
+def generate_event_behavior_control_decl(event_enum_name):
+    ret = mcgen('''
+
+typedef void (*QAPIEventFuncEmit)(%(event_enum_name)s ev,
+                                  QDict *dict,
+                                  Error **errp);

Why does the emit function need 'ev'? Doesn't 'dict' contain all the
info it needs? Also, it's better to rename it to 'event' or 'qmp_event'.


   ev is for rate limit. I didn't move rate limit logic from callback to
internal, mainly because it is a generated function, which seems
too complex. And the genrated function was not moved into a separte
file mainly because the enum and including issue, see the comments
in script above.
   The problem is enum is changing, so the new file include it need
to recompile, for example, test schema and qapi-schema.json may
force recompile twice, I am not sure if it is good to do
some tricks in build system.

  I am going to respin this series after sync with upstream.
"ev" will be removed, and will try use a runtime call to solve
issue above.




reply via email to

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