The qapi schema has per-target definitions. Generate the marshaller, events and introspection per target. Keep the types, visitors and headers generic to keep common code unaware. However, having per-target events requires block events stubs.
The following patch will use config headers to conditionally remove disabled features from the schema. Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- stubs/qapi-event.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 54 +++++++++++++++----------------------- Makefile.objs | 7 +---- Makefile.target | 23 +++++++++++++++++ stubs/Makefile.objs | 1 + qapi.mak | 14 ++++++++++ 6 files changed, 133 insertions(+), 40 deletions(-) create mode 100644 stubs/qapi-event.c create mode 100644 qapi.mak diff --git a/stubs/qapi-event.c b/stubs/qapi-event.c new file mode 100644 index 0000000..73b5424 --- /dev/null +++ b/stubs/qapi-event.c @@ -0,0 +1,74 @@ +#include "qemu/osdep.h" +#include "qapi-event.h" + +void qapi_event_send_device_tray_moved(const char *device, bool tray_open, + Error **errp) +{ +} + +void qapi_event_send_quorum_report_bad(QuorumOpType type, bool has_error, + const char *error, const char *node_name, + int64_t sector_num, + int64_t sectors_count, Error **errp) +{ +} + +void qapi_event_send_quorum_failure(const char *reference, int64_t sector_num, + int64_t sectors_count, Error **errp) +{ +} + +void qapi_event_send_block_job_cancelled(BlockJobType type, const char *device, + int64_t len, int64_t offset, + int64_t speed, Error **errp) +{ +} + +void qapi_event_send_block_job_completed(BlockJobType type, const char *device, + int64_t len, int64_t offset, + int64_t speed, bool has_error, + const char *error, Error **errp) +{ +} + +void qapi_event_send_block_job_error(const char *device, + IoOperationType operation, + BlockErrorAction action, Error **errp) +{ +} + +void qapi_event_send_block_job_ready(BlockJobType type, const char *device, + int64_t len, int64_t offset, int64_t speed, + Error **errp) +{ +} + +void qapi_event_send_block_io_error(const char *device, + IoOperationType operation, + BlockErrorAction action, bool has_nospace, + bool nospace, const char *reason, + Error **errp) +{ +} + +void qapi_event_send_block_image_corrupted(const char *device, + bool has_node_name, + const char *node_name, + const char *msg, bool has_offset, + int64_t offset, bool has_size, + int64_t size, bool fatal, + Error **errp) +{ +} + +void qapi_event_send_block_write_threshold(const char *node_name, + uint64_t amount_exceeded, + uint64_t write_threshold, + Error **errp) +{ +} + +void qapi_event_send_device_deleted(bool has_device, const char *device, + const char *path, Error **errp) +{ +} diff --git a/Makefile b/Makefile index 50b4b3a..83d27fb 100644 --- a/Makefile +++ b/Makefile @@ -49,12 +49,11 @@ endif endif include $(SRC_PATH)/rules.mak +include $(SRC_PATH)/qapi.mak GENERATED_HEADERS = qemu-version.h config-host.h qemu-options.def GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h -GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c -GENERATED_HEADERS += qmp-introspect.h -GENERATED_SOURCES += qmp-introspect.c +GENERATED_SOURCES += qapi-types.c qapi-visit.c GENERATED_HEADERS += trace/generated-events.h GENERATED_SOURCES += trace/generated-events.c @@ -268,56 +267,43 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated -gen-out-type = $(subst .,-,$(suffix $@)) - -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-types-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ " GEN $@") qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-visit-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ " GEN $@") qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ -$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) +$(SRC_PATH)/qga/qapi-schema.json $(qapi-commands-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ + $(qapi-gen-type) -o qga/qapi-generated -p "qga-" $<, \ " GEN $@") -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ - $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ - $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ - $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ - $(SRC_PATH)/qapi/trace.json - qapi-types.c qapi-types.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +$(qapi-modules) $(qapi-types-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o "." -b $<, \ + $(qapi-gen-type) -o "." -b $<, \ " GEN $@") qapi-visit.c qapi-visit.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +$(qapi-modules) $(qapi-visit-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o "." -b $<, \ + $(qapi-gen-type) -o "." -b $<, \ " GEN $@") -qapi-event.c qapi-event.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) + +qapi-event.h :\ +$(qapi-modules) $(qapi-event-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o "." $<, \ + $(qapi-gen-type) -o "." $<, \ " GEN $@") -qmp-commands.h qmp-marshal.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + +qmp-commands.h :\ +$(qapi-modules) $(qapi-commands-py) $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." -m $<, \ - " GEN $@") -qmp-introspect.h qmp-introspect.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o "." $<, \ + $(qapi-gen-type) -o "." -m $<, \ " GEN $@") QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) diff --git a/Makefile.objs b/Makefile.objs index 6d5ddcf..7addab8 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -2,7 +2,7 @@ # Common libraries for tools and emulators stub-obj-y = stubs/ crypto/ util-obj-y = util/ qobject/ qapi/ -util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o +util-obj-y += qapi-types.o qapi-visit.o ####################################################################### # block-obj-y is code used by both qemu system emulation and qemu-img @@ -78,11 +78,6 @@ common-obj-$(CONFIG_SECCOMP) += qemu-seccomp.o common-obj-$(CONFIG_FDT) += device_tree.o -###################################################################### -# qapi - -common-obj-y += qmp-marshal.o -common-obj-y += qmp-introspect.o common-obj-y += qmp.o hmp.o endif diff --git a/Makefile.target b/Makefile.target index a440bcb..6b672eb 100644 --- a/Makefile.target +++ b/Makefile.target @@ -6,6 +6,7 @@ include ../config-host.mak include config-target.mak include config-devices.mak include $(SRC_PATH)/rules.mak +include $(SRC_PATH)/qapi.mak $(call set-vpath, $(SRC_PATH):$(BUILD_DIR)) ifdef CONFIG_LINUX @@ -157,6 +158,28 @@ obj-y += hw/$(TARGET_BASE_ARCH)/ endif GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h +GENERATED_HEADERS += qmp-introspect.h +GENERATED_SOURCES += qmp-introspect.c qmp-marshal.c qapi-event.c + +qmp-marshal.c :\ +$(qapi-modules) $(qapi-commands-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ + $(qapi-gen-type) -o "." -m $<, \ + " GEN $(TARGET_DIR)$@") + +qapi-event.c :\ +$(qapi-modules) $(qapi-event-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ + $(qapi-gen-type) -o "." $<, \ + " GEN $@") + +qmp-introspect.h qmp-introspect.c :\ +$(qapi-modules) $(qapi-introspect-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ + $(qapi-gen-type) -o "." $<, \ + " GEN $(TARGET_DIR)$@") + +obj-y += qmp-marshal.o qmp-introspect.o qapi-event.o endif # CONFIG_SOFTMMU diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 55edd15..aa2cbef 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -45,3 +45,4 @@ stub-obj-y += iohandler.o stub-obj-y += smbios_type_38.o stub-obj-y += ipmi.o stub-obj-y += pc_madt_cpu_entry.o +stub-obj-y += qapi-event.o diff --git a/qapi.mak b/qapi.mak new file mode 100644 index 0000000..4e26714 --- /dev/null +++ b/qapi.mak @@ -0,0 +1,14 @@ +qapi-gen-type = $(subst .,-,$(suffix $@)) + +qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ + $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ + $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \ + $(SRC_PATH)/qapi/crypto.json $(SRC_PATH)/qapi/rocker.json \ + $(SRC_PATH)/qapi/trace.json + +qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py + +qapi-types-py = $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) +qapi-visit-py = $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) +qapi-commands-py = $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) +qapi-introspect-py = $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) -- 2.9.0