From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 05/18] qapi: Generate QAPIEvent stuff into separate files
Date: Mon, 18 Feb 2019 15:05:54 +0100 [thread overview]
Message-ID: <20190218140607.31998-6-armbru@redhat.com> (raw)
In-Reply-To: <20190218140607.31998-1-armbru@redhat.com>
Having to include qapi-events.h just for QAPIEvent is suboptimal, but
quite tolerable now. It'll become problematic when we have events
conditional on the target, because then qapi-events.h won't be usable
from target-independent code anymore. Avoid that by generating it
into separate files.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190214152251.2073-6-armbru@redhat.com>
---
.gitignore | 1 +
Makefile | 1 +
Makefile.objs | 1 +
docs/devel/qapi-code-gen.txt | 48 ++++++++++++++++++++++++------------
monitor.c | 2 +-
scripts/qapi/events.py | 32 +++++++++++++++---------
stubs/monitor.c | 2 +-
tests/test-qmp-event.c | 1 +
ui/vnc.c | 3 ++-
9 files changed, 61 insertions(+), 30 deletions(-)
diff --git a/.gitignore b/.gitignore
index 321095bf1a..b66b772551 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@
/qapi/qapi-builtin-visit.[ch]
/qapi/qapi-commands-*.[ch]
/qapi/qapi-commands.[ch]
+/qapi/qapi-emit-events.[ch]
/qapi/qapi-events-*.[ch]
/qapi/qapi-events.[ch]
/qapi/qapi-introspect.[ch]
diff --git a/Makefile b/Makefile
index 3658310b95..53d161b65f 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,7 @@ GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
+GENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
diff --git a/Makefile.objs b/Makefile.objs
index b7aae33367..ec11a0f55b 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -12,6 +12,7 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o)
util-obj-y += qapi/qapi-builtin-visit.o
util-obj-y += qapi/qapi-visit.o
util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o)
+util-obj-y += qapi/qapi-emit-events.o
util-obj-y += qapi/qapi-events.o
util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
util-obj-y += qapi/qapi-introspect.o
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index c9ba8ddb2e..b517b0cfbf 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1381,11 +1381,15 @@ qapi_event_send_EVENT().
The following files are created:
-$(prefix)qapi-events.h - Function prototypes for each event type, plus an
- enumeration of all event names
+$(prefix)qapi-events.h - Function prototypes for each event type
$(prefix)qapi-events.c - Implementation of functions to send an event
+$(prefix)qapi-emit-events.h - Enumeration of all event names, and
+ common event code declarations
+
+$(prefix)qapi-emit-events.c - Common event code definitions
+
Example:
$ cat qapi-generated/example-qapi-events.h
@@ -1397,9 +1401,32 @@ Example:
#include "qapi/util.h"
#include "example-qapi-types.h"
-
void qapi_event_send_my_event(void);
+ #endif /* EXAMPLE_QAPI_EVENTS_H */
+ $ cat qapi-generated/example-qapi-events.c
+[Uninteresting stuff omitted...]
+
+ void qapi_event_send_my_event(void)
+ {
+ QDict *qmp;
+
+ qmp = qmp_event_build_dict("MY_EVENT");
+
+ example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp);
+
+ qobject_unref(qmp);
+ }
+
+[Uninteresting stuff omitted...]
+ $ cat qapi-generated/example-qapi-emit-events.h
+[Uninteresting stuff omitted...]
+
+ #ifndef EXAMPLE_QAPI_EMIT_EVENTS_H
+ #define EXAMPLE_QAPI_EMIT_EVENTS_H
+
+ #include "qapi/util.h"
+
typedef enum example_QAPIEvent {
EXAMPLE_QAPI_EVENT_MY_EVENT,
EXAMPLE_QAPI_EVENT__MAX,
@@ -1412,21 +1439,10 @@ Example:
void example_qapi_event_emit(example_QAPIEvent event, QDict *qdict);
- #endif /* EXAMPLE_QAPI_EVENTS_H */
- $ cat qapi-generated/example-qapi-events.c
+ #endif /* EXAMPLE_QAPI_EMIT_EVENTS_H */
+ $ cat qapi-generated/example-qapi-emit-events.c
[Uninteresting stuff omitted...]
- void qapi_event_send_my_event(void)
- {
- QDict *qmp;
-
- qmp = qmp_event_build_dict("MY_EVENT");
-
- example_qapi_event_emit(EXAMPLE_QAPI_EVENT_MY_EVENT, qmp);
-
- qobject_unref(qmp);
- }
-
const QEnumLookup example_QAPIEvent_lookup = {
.array = (const char *const[]) {
[EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT",
diff --git a/monitor.c b/monitor.c
index e5de5765b8..8e02a001a3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -75,7 +75,7 @@
#include "qemu/thread.h"
#include "block/qapi.h"
#include "qapi/qapi-commands.h"
-#include "qapi/qapi-events.h"
+#include "qapi/qapi-emit-events.h"
#include "qapi/error.h"
#include "qapi/qmp-event.h"
#include "qapi/qapi-introspect.h"
diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
index 6f39cf8196..28bbc3745d 100644
--- a/scripts/qapi/events.py
+++ b/scripts/qapi/events.py
@@ -143,12 +143,14 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
self._event_emit_name = c_name(prefix + 'qapi_event_emit')
def _begin_user_module(self, name):
+ events = self._module_basename('qapi-events', name)
types = self._module_basename('qapi-types', name)
visit = self._module_basename('qapi-visit', name)
self._genc.add(mcgen('''
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "%(prefix)sqapi-events.h"
+#include "%(prefix)sqapi-emit-events.h"
+#include "%(events)s.h"
#include "%(visit)s.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
@@ -156,26 +158,34 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
#include "qapi/qmp-event.h"
''',
- visit=visit, prefix=self._prefix))
+ events=events, visit=visit,
+ prefix=self._prefix))
self._genh.add(mcgen('''
#include "qapi/util.h"
#include "%(types)s.h"
-
''',
types=types))
def visit_end(self):
- (genc, genh) = self._module[self._main_module]
- genh.add(gen_enum(self._event_enum_name,
- self._event_enum_members))
- genc.add(gen_enum_lookup(self._event_enum_name,
- self._event_enum_members))
- genh.add(mcgen('''
+ self._add_system_module('emit', ' * QAPI Events emission')
+ self._genc.preamble_add(mcgen('''
+#include "qemu/osdep.h"
+#include "%(prefix)sqapi-emit-events.h"
+''',
+ prefix=self._prefix))
+ self._genh.preamble_add(mcgen('''
+#include "qapi/util.h"
+'''))
+ self._genh.add(gen_enum(self._event_enum_name,
+ self._event_enum_members))
+ self._genc.add(gen_enum_lookup(self._event_enum_name,
+ self._event_enum_members))
+ self._genh.add(mcgen('''
void %(event_emit)s(%(event_enum)s event, QDict *qdict);
''',
- event_emit=self._event_emit_name,
- event_enum=self._event_enum_name))
+ event_emit=self._event_emit_name,
+ event_enum=self._event_enum_name))
def visit_event(self, name, info, ifcond, arg_type, boxed):
with ifcontext(ifcond, self._genh, self._genc):
diff --git a/stubs/monitor.c b/stubs/monitor.c
index 32bd7012c3..b57fe6c32f 100644
--- a/stubs/monitor.c
+++ b/stubs/monitor.c
@@ -1,6 +1,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qapi/qapi-events.h"
+#include "qapi/qapi-emit-events.h"
#include "qemu-common.h"
#include "monitor/monitor.h"
diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c
index bf900f14f4..eee7e08ab6 100644
--- a/tests/test-qmp-event.c
+++ b/tests/test-qmp-event.c
@@ -21,6 +21,7 @@
#include "qapi/qmp/qstring.h"
#include "qapi/qmp-event.h"
#include "test-qapi-events.h"
+#include "test-qapi-emit-events.h"
typedef struct TestEventData {
QDict *expect;
diff --git a/ui/vnc.c b/ui/vnc.c
index 0fef646fc4..7e0710ed8f 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -35,7 +35,8 @@
#include "qemu/timer.h"
#include "qemu/acl.h"
#include "qemu/config-file.h"
-#include "qapi/qapi-events.h"
+#include "qapi/qapi-emit-events.h"
+#include "qapi/qapi-events-ui.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
#include "ui/input.h"
--
2.17.2
next prev parent reply other threads:[~2019-02-18 14:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 14:05 [Qemu-devel] [PULL 00/18] QAPI patches for 2019-02-18 Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 01/18] qapi: Belatedly document modular code generation Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 02/18] qapi: Fix up documentation for recent commit a95291007b2 Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 03/18] qapi: Clean up modular built-in code generation a bit Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 04/18] qapi: Prepare for system modules other than 'builtin' Markus Armbruster
2019-02-18 14:05 ` Markus Armbruster [this message]
2019-02-18 14:05 ` [Qemu-devel] [PULL 06/18] build-sys: move qmp-introspect per target Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 07/18] build: Deal with all of QAPI's .o in qapi/Makefile.objs Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 08/18] qapi: New module target.json Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 09/18] qapi: make rtc-reset-reinjection and SEV depend on TARGET_I386 Markus Armbruster
2019-02-18 14:05 ` [Qemu-devel] [PULL 10/18] qapi: make s390 commands depend on TARGET_S390X Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 11/18] target.json: add a note about query-cpu* not being s390x-specific Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 12/18] qapi: make query-gic-capabilities depend on TARGET_ARM Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 13/18] qapi: make query-cpu-model-expansion depend on s390 or x86 Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 14/18] qapi: make query-cpu-definitions depend on specific targets Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 15/18] qapi: remove qmp_unregister_command() Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 16/18] Revert "qapi-events: add 'if' condition to implicit event enum" Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 17/18] qmp: Deprecate query-events in favor of query-qmp-schema Markus Armbruster
2019-02-18 14:06 ` [Qemu-devel] [PULL 18/18] qapi: move RTC_CHANGE to the target schema Markus Armbruster
2021-09-23 13:14 ` Peter Maydell
2021-09-23 13:37 ` Paolo Bonzini
2021-09-24 12:21 ` Markus Armbruster
2021-09-24 12:28 ` Marc-André Lureau
2021-09-24 12:40 ` Peter Maydell
2021-09-24 12:39 ` Peter Maydell
2021-09-24 13:35 ` Markus Armbruster
2021-09-24 14:42 ` Daniel P. Berrangé
2021-09-24 15:02 ` Peter Maydell
2021-09-25 7:39 ` Markus Armbruster
2019-02-18 16:19 ` [Qemu-devel] [PULL 00/18] QAPI patches for 2019-02-18 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190218140607.31998-6-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).