Skip to content
This repository has been archived by the owner on Apr 13, 2019. It is now read-only.

Commit

Permalink
qapi: Move qapi-schema.json to qapi/, rename generated files
Browse files Browse the repository at this point in the history
Move qapi-schema.json to qapi/, so it's next to its modules, and all
files get generated to qapi/, not just the ones generated for modules.

Consistently name the generated files qapi-MODULE.EXT:
qmp-commands.[ch] become qapi-commands.[ch], qapi-event.[ch] become
qapi-events.[ch], and qmp-introspect.[ch] become qapi-introspect.[ch].
This gets rid of the temporary hacks in scripts/qapi/commands.py,
scripts/qapi/events.py, and scripts/qapi/common.py.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180211093607.27351-28-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
[eblake: Fix trailing dot in tpm.c, undo temporary hack for OSX toolchain]
Signed-off-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
Markus Armbruster authored and ebblake committed Mar 2, 2018
1 parent bb46af4 commit eb815e2
Show file tree
Hide file tree
Showing 35 changed files with 119 additions and 134 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
/qga/qapi-generated
/qapi-generated
/qapi-gen-timestamp
/qapi-builtin-types.[ch]
/qapi-builtin-visit.[ch]
/qapi/qapi-builtin-types.[ch]
/qapi/qapi-builtin-visit.[ch]
/qapi/qapi-commands-block-core.[ch]
/qapi/qapi-commands-block.[ch]
/qapi/qapi-commands-char.[ch]
Expand All @@ -47,6 +47,7 @@
/qapi/qapi-commands-trace.[ch]
/qapi/qapi-commands-transaction.[ch]
/qapi/qapi-commands-ui.[ch]
/qapi/qapi-commands.[ch]
/qapi/qapi-events-block-core.[ch]
/qapi/qapi-events-block.[ch]
/qapi/qapi-events-char.[ch]
Expand All @@ -63,6 +64,8 @@
/qapi/qapi-events-trace.[ch]
/qapi/qapi-events-transaction.[ch]
/qapi/qapi-events-ui.[ch]
/qapi/qapi-events.[ch]
/qapi/qapi-introspect.[ch]
/qapi/qapi-types-block-core.[ch]
/qapi/qapi-types-block.[ch]
/qapi/qapi-types-char.[ch]
Expand All @@ -79,7 +82,7 @@
/qapi/qapi-types-trace.[ch]
/qapi/qapi-types-transaction.[ch]
/qapi/qapi-types-ui.[ch]
/qapi-types.[ch]
/qapi/qapi-types.[ch]
/qapi/qapi-visit-block-core.[ch]
/qapi/qapi-visit-block.[ch]
/qapi/qapi-visit-char.[ch]
Expand All @@ -96,11 +99,8 @@
/qapi/qapi-visit-trace.[ch]
/qapi/qapi-visit-transaction.[ch]
/qapi/qapi-visit-ui.[ch]
/qapi-visit.[ch]
/qapi-event.[ch]
/qapi-doc.texi
/qmp-commands.[ch]
/qmp-introspect.[ch]
/qapi/qapi-visit.[ch]
/qapi/qapi-doc.texi
/qemu-doc.html
/qemu-doc.info
/qemu-doc.txt
Expand Down
42 changes: 21 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ endif
include $(SRC_PATH)/rules.mak

GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c
GENERATED_FILES += qapi-types.h qapi-types.c
GENERATED_FILES += qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
GENERATED_FILES += qapi/qapi-types.h qapi/qapi-types.c
GENERATED_FILES += qapi/qapi-types-block-core.h qapi/qapi-types-block-core.c
GENERATED_FILES += qapi/qapi-types-block.h qapi/qapi-types-block.c
GENERATED_FILES += qapi/qapi-types-char.h qapi/qapi-types-char.c
Expand All @@ -108,8 +108,8 @@ GENERATED_FILES += qapi/qapi-types-tpm.h qapi/qapi-types-tpm.c
GENERATED_FILES += qapi/qapi-types-trace.h qapi/qapi-types-trace.c
GENERATED_FILES += qapi/qapi-types-transaction.h qapi/qapi-types-transaction.c
GENERATED_FILES += qapi/qapi-types-ui.h qapi/qapi-types-ui.c
GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c
GENERATED_FILES += qapi-visit.h qapi-visit.c
GENERATED_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
GENERATED_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
GENERATED_FILES += qapi/qapi-visit-block-core.h qapi/qapi-visit-block-core.c
GENERATED_FILES += qapi/qapi-visit-block.h qapi/qapi-visit-block.c
GENERATED_FILES += qapi/qapi-visit-char.h qapi/qapi-visit-char.c
Expand All @@ -126,7 +126,7 @@ GENERATED_FILES += qapi/qapi-visit-tpm.h qapi/qapi-visit-tpm.c
GENERATED_FILES += qapi/qapi-visit-trace.h qapi/qapi-visit-trace.c
GENERATED_FILES += qapi/qapi-visit-transaction.h qapi/qapi-visit-transaction.c
GENERATED_FILES += qapi/qapi-visit-ui.h qapi/qapi-visit-ui.c
GENERATED_FILES += qmp-commands.h qmp-commands.c
GENERATED_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
GENERATED_FILES += qapi/qapi-commands-block-core.h qapi/qapi-commands-block-core.c
GENERATED_FILES += qapi/qapi-commands-block.h qapi/qapi-commands-block.c
GENERATED_FILES += qapi/qapi-commands-char.h qapi/qapi-commands-char.c
Expand All @@ -143,7 +143,7 @@ GENERATED_FILES += qapi/qapi-commands-tpm.h qapi/qapi-commands-tpm.c
GENERATED_FILES += qapi/qapi-commands-trace.h qapi/qapi-commands-trace.c
GENERATED_FILES += qapi/qapi-commands-transaction.h qapi/qapi-commands-transaction.c
GENERATED_FILES += qapi/qapi-commands-ui.h qapi/qapi-commands-ui.c
GENERATED_FILES += qapi-event.h qapi-event.c
GENERATED_FILES += qapi/qapi-events.h qapi/qapi-events.c
GENERATED_FILES += qapi/qapi-events-block-core.h qapi/qapi-events-block-core.c
GENERATED_FILES += qapi/qapi-events-block.h qapi/qapi-events-block.c
GENERATED_FILES += qapi/qapi-events-char.h qapi/qapi-events-char.c
Expand All @@ -160,8 +160,8 @@ GENERATED_FILES += qapi/qapi-events-tpm.h qapi/qapi-events-tpm.c
GENERATED_FILES += qapi/qapi-events-trace.h qapi/qapi-events-trace.c
GENERATED_FILES += qapi/qapi-events-transaction.h qapi/qapi-events-transaction.c
GENERATED_FILES += qapi/qapi-events-ui.h qapi/qapi-events-ui.c
GENERATED_FILES += qmp-introspect.c qmp-introspect.h
GENERATED_FILES += qapi-doc.texi
GENERATED_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
GENERATED_FILES += qapi/qapi-doc.texi

GENERATED_FILES += trace/generated-tcg-tracers.h

Expand Down Expand Up @@ -562,7 +562,7 @@ $(SRC_PATH)/scripts/qapi-gen.py

qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-commands.c \
qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
qga/qapi-generated/qga-qapi-doc.texi: \
qga/qapi-generated/qapi-gen-timestamp ;
qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
Expand All @@ -571,7 +571,7 @@ qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-p
"GEN","$(@:%-timestamp=%)")
@>$@

qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json $(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
$(SRC_PATH)/qapi/char.json \
$(SRC_PATH)/qapi/crypto.json \
Expand All @@ -587,8 +587,8 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/transaction.json \
$(SRC_PATH)/qapi/ui.json

qapi-builtin-types.c qapi-builtin-types.h \
qapi-types.c qapi-types.h \
qapi/qapi-builtin-types.c qapi/qapi-builtin-types.h \
qapi/qapi-types.c qapi/qapi-types.h \
qapi/qapi-types-block-core.c qapi/qapi-types-block-core.h \
qapi/qapi-types-block.c qapi/qapi-types-block.h \
qapi/qapi-types-char.c qapi/qapi-types-char.h \
Expand All @@ -605,8 +605,8 @@ qapi/qapi-types-tpm.c qapi/qapi-types-tpm.h \
qapi/qapi-types-trace.c qapi/qapi-types-trace.h \
qapi/qapi-types-transaction.c qapi/qapi-types-transaction.h \
qapi/qapi-types-ui.c qapi/qapi-types-ui.h \
qapi-builtin-visit.c qapi-builtin-visit.h \
qapi-visit.c qapi-visit.h \
qapi/qapi-builtin-visit.c qapi/qapi-builtin-visit.h \
qapi/qapi-visit.c qapi/qapi-visit.h \
qapi/qapi-visit-block-core.c qapi/qapi-visit-block-core.h \
qapi/qapi-visit-block.c qapi/qapi-visit-block.h \
qapi/qapi-visit-char.c qapi/qapi-visit-char.h \
Expand All @@ -623,7 +623,7 @@ qapi/qapi-visit-tpm.c qapi/qapi-visit-tpm.h \
qapi/qapi-visit-trace.c qapi/qapi-visit-trace.h \
qapi/qapi-visit-transaction.c qapi/qapi-visit-transaction.h \
qapi/qapi-visit-ui.c qapi/qapi-visit-ui.h \
qmp-commands.h qmp-commands.c \
qapi/qapi-commands.h qapi/qapi-commands.c \
qapi/qapi-commands-block-core.c qapi/qapi-commands-block-core.h \
qapi/qapi-commands-block.c qapi/qapi-commands-block.h \
qapi/qapi-commands-char.c qapi/qapi-commands-char.h \
Expand All @@ -640,7 +640,7 @@ qapi/qapi-commands-tpm.c qapi/qapi-commands-tpm.h \
qapi/qapi-commands-trace.c qapi/qapi-commands-trace.h \
qapi/qapi-commands-transaction.c qapi/qapi-commands-transaction.h \
qapi/qapi-commands-ui.c qapi/qapi-commands-ui.h \
qapi-event.c qapi-event.h \
qapi/qapi-events.c qapi/qapi-events.h \
qapi/qapi-events-block-core.c qapi/qapi-events-block-core.h \
qapi/qapi-events-block.c qapi/qapi-events-block.h \
qapi/qapi-events-char.c qapi/qapi-events-char.h \
Expand All @@ -657,16 +657,16 @@ qapi/qapi-events-tpm.c qapi/qapi-events-tpm.h \
qapi/qapi-events-trace.c qapi/qapi-events-trace.h \
qapi/qapi-events-transaction.c qapi/qapi-events-transaction.h \
qapi/qapi-events-ui.c qapi/qapi-events-ui.h \
qmp-introspect.h qmp-introspect.c \
qapi-doc.texi: \
qapi/qapi-introspect.h qapi/qapi-introspect.c \
qapi/qapi-doc.texi: \
qapi-gen-timestamp ;
qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-gen.py \
-o "." -b $<, \
-o "qapi" -b $<, \
"GEN","$(@:%-timestamp=%)")
@>$@

QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h)
$(qga-obj-y): $(QGALIB_GEN)

qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
Expand Down Expand Up @@ -933,7 +933,7 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt
qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")

docs/interop/qemu-qmp-qapi.texi: qapi-doc.texi
docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
@cp -p $< $@

docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
Expand Down
21 changes: 11 additions & 10 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Common libraries for tools and emulators
stub-obj-y = stubs/ crypto/
util-obj-y = util/ qobject/ qapi/
util-obj-y += qapi-builtin-types.o
util-obj-y += qapi-types.o
util-obj-y += qapi/qapi-builtin-types.o
util-obj-y += qapi/qapi-types.o
util-obj-y += qapi/qapi-types-block-core.o
util-obj-y += qapi/qapi-types-block.o
util-obj-y += qapi/qapi-types-char.o
Expand All @@ -20,8 +20,8 @@ util-obj-y += qapi/qapi-types-tpm.o
util-obj-y += qapi/qapi-types-trace.o
util-obj-y += qapi/qapi-types-transaction.o
util-obj-y += qapi/qapi-types-ui.o
util-obj-y += qapi-builtin-visit.o
util-obj-y += qapi-visit.o
util-obj-y += qapi/qapi-builtin-visit.o
util-obj-y += qapi/qapi-visit.o
util-obj-y += qapi/qapi-visit-block-core.o
util-obj-y += qapi/qapi-visit-block.o
util-obj-y += qapi/qapi-visit-char.o
Expand All @@ -38,7 +38,7 @@ util-obj-y += qapi/qapi-visit-tpm.o
util-obj-y += qapi/qapi-visit-trace.o
util-obj-y += qapi/qapi-visit-transaction.o
util-obj-y += qapi/qapi-visit-ui.o
util-obj-y += qapi-event.o
util-obj-y += qapi/qapi-events.o
util-obj-y += qapi/qapi-events-block-core.o
util-obj-y += qapi/qapi-events-block.o
util-obj-y += qapi/qapi-events-char.o
Expand All @@ -55,7 +55,7 @@ util-obj-y += qapi/qapi-events-tpm.o
util-obj-y += qapi/qapi-events-trace.o
util-obj-y += qapi/qapi-events-transaction.o
util-obj-y += qapi/qapi-events-ui.o
util-obj-y += qmp-introspect.o
util-obj-y += qapi/qapi-introspect.o

chardev-obj-y = chardev/

Expand Down Expand Up @@ -131,7 +131,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o
######################################################################
# qapi

common-obj-y += qmp-commands.o
common-obj-y += qapi/qapi-commands.o
common-obj-y += qapi/qapi-commands-block-core.o
common-obj-y += qapi/qapi-commands-block.o
common-obj-y += qapi/qapi-commands-char.o
Expand All @@ -148,7 +148,7 @@ common-obj-y += qapi/qapi-commands-tpm.o
common-obj-y += qapi/qapi-commands-trace.o
common-obj-y += qapi/qapi-commands-transaction.o
common-obj-y += qapi/qapi-commands-ui.o
common-obj-y += qmp-introspect.o
common-obj-y += qapi/qapi-introspect.o
common-obj-y += qmp.o hmp.o
endif

Expand All @@ -171,8 +171,9 @@ target-obj-y += trace/
######################################################################
# guest agent

# FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed
# by libqemuutil.a. These should be moved to a separate .json schema.
# FIXME: a few definitions from qapi/qapi-types.o and
# qapi/qapi-visit.o are needed by libqemuutil.a. These should be
# extracted into a QAPI schema module, or perhaps a separate schema.
qga-obj-y = qga/
qga-vss-dll-obj-y = qga/

Expand Down
2 changes: 1 addition & 1 deletion backends/hostmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "sysemu/hostmem.h"
#include "hw/boards.h"
#include "qapi/error.h"
#include "qapi-builtin-visit.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/visitor.h"
#include "qemu/config-file.h"
#include "qom/object_interfaces.h"
Expand Down
30 changes: 15 additions & 15 deletions docs/devel/qapi-code-gen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ name an event 'MAX', since the generator also produces a C enumeration
of all event names with a generated _MAX value at the end. When
'data' is also specified, additional info will be included in the
event, with similar semantics to a 'struct' expression. Finally there
will be C API generated in qapi-event.h; when called by QEMU code, a
will be C API generated in qapi-events.h; when called by QEMU code, a
message with timestamp will be emitted on the wire.

An example event is:
Expand Down Expand Up @@ -1147,15 +1147,15 @@ declares qmp_COMMAND() that the user must implement.

The following files are generated:

$(prefix)qmp-commands.c: Command marshal/dispatch functions for each
QMP command defined in the schema
$(prefix)qapi-commands.c: Command marshal/dispatch functions for each
QMP command defined in the schema

$(prefix)qmp-commands.h: Function prototypes for the QMP commands
specified in the schema
$(prefix)qapi-commands.h: Function prototypes for the QMP commands
specified in the schema

Example:

$ cat qapi-generated/example-qmp-commands.h
$ cat qapi-generated/example-qapi-commands.h
[Uninteresting stuff omitted...]

#ifndef EXAMPLE_QMP_COMMANDS_H
Expand All @@ -1170,7 +1170,7 @@ Example:
void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp);

#endif
$ cat qapi-generated/example-qmp-commands.c
$ cat qapi-generated/example-qapi-commands.c
[Uninteresting stuff omitted...]

static void qmp_marshal_output_UserDefOne(UserDefOne *ret_in, QObject **ret_out, Error **errp)
Expand Down Expand Up @@ -1243,14 +1243,14 @@ qapi_event_send_EVENT().

The following files are created:

$(prefix)qapi-event.h - Function prototypes for each event type, plus an
$(prefix)qapi-events.h - Function prototypes for each event type, plus an
enumeration of all event names

$(prefix)qapi-event.c - Implementation of functions to send an event
$(prefix)qapi-events.c - Implementation of functions to send an event

Example:

$ cat qapi-generated/example-qapi-event.h
$ cat qapi-generated/example-qapi-events.h
[Uninteresting stuff omitted...]

#ifndef EXAMPLE_QAPI_EVENT_H
Expand All @@ -1273,7 +1273,7 @@ Example:
extern const char *const example_QAPIEvent_lookup[];

#endif
$ cat qapi-generated/example-qapi-event.c
$ cat qapi-generated/example-qapi-events.c
[Uninteresting stuff omitted...]

void qapi_event_send_my_event(Error **errp)
Expand Down Expand Up @@ -1306,14 +1306,14 @@ Example:

The following files are created:

$(prefix)qmp-introspect.c - Defines a string holding a JSON
$(prefix)qapi-introspect.c - Defines a string holding a JSON
description of the schema

$(prefix)qmp-introspect.h - Declares the above string
$(prefix)qapi-introspect.h - Declares the above string

Example:

$ cat qapi-generated/example-qmp-introspect.h
$ cat qapi-generated/example-qapi-introspect.h
[Uninteresting stuff omitted...]

#ifndef EXAMPLE_QMP_INTROSPECT_H
Expand All @@ -1322,7 +1322,7 @@ Example:
extern const char example_qmp_schema_json[];

#endif
$ cat qapi-generated/example-qmp-introspect.c
$ cat qapi-generated/example-qapi-introspect.c
[Uninteresting stuff omitted...]

const char example_qmp_schema_json[] = "["
Expand Down
2 changes: 1 addition & 1 deletion docs/devel/writing-qmp-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ There are a number of things to be noticed:
allocated by the implementation. This is so because the QAPI also generates
a function to free its types and it cannot distinguish between dynamically
or statically allocated strings
6. You have to include "qapi/qmp-commands-misc.h" in qemu-timer.c
6. You have to include "qapi/qapi-commands-misc.h" in qemu-timer.c

Time to test the new command. Build qemu, run it as described in the "Testing"
section and try this:
Expand Down
2 changes: 1 addition & 1 deletion docs/interop/qmp-intro.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Escape character is '^]'.
}

Please refer to docs/interop/qemu-qmp-ref.* for a complete command
reference, generated from qapi-schema.json.
reference, generated from qapi/qapi-schema.json.

QMP wiki page
-------------
Expand Down
2 changes: 1 addition & 1 deletion hmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "monitor/qdev.h"
#include "qapi/error.h"
#include "qapi/opts-visitor.h"
#include "qapi-builtin-visit.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/qapi-commands-block.h"
#include "qapi/qapi-commands-char.h"
#include "qapi/qapi-commands-migration.h"
Expand Down
2 changes: 1 addition & 1 deletion include/qapi/qmp/qobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifndef QOBJECT_H
#define QOBJECT_H

#include "qapi-builtin-types.h"
#include "qapi/qapi-builtin-types.h"

struct QObject {
QType type;
Expand Down
Loading

0 comments on commit eb815e2

Please sign in to comment.