diff options
189 files changed, 1569 insertions, 1355 deletions
diff --git a/.gitignore b/.gitignore index 704b22285d..4055e12ee8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,13 +27,79 @@ /libuser /linux-headers/asm /qga/qapi-generated -/qapi-generated -/qapi-types.[ch] -/qapi-visit.[ch] -/qapi-event.[ch] -/qmp-commands.h -/qmp-introspect.[ch] -/qmp-marshal.c +/qapi-gen-timestamp +/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] +/qapi/qapi-commands-common.[ch] +/qapi/qapi-commands-crypto.[ch] +/qapi/qapi-commands-introspect.[ch] +/qapi/qapi-commands-migration.[ch] +/qapi/qapi-commands-misc.[ch] +/qapi/qapi-commands-net.[ch] +/qapi/qapi-commands-rocker.[ch] +/qapi/qapi-commands-run-state.[ch] +/qapi/qapi-commands-sockets.[ch] +/qapi/qapi-commands-tpm.[ch] +/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] +/qapi/qapi-events-common.[ch] +/qapi/qapi-events-crypto.[ch] +/qapi/qapi-events-introspect.[ch] +/qapi/qapi-events-migration.[ch] +/qapi/qapi-events-misc.[ch] +/qapi/qapi-events-net.[ch] +/qapi/qapi-events-rocker.[ch] +/qapi/qapi-events-run-state.[ch] +/qapi/qapi-events-sockets.[ch] +/qapi/qapi-events-tpm.[ch] +/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] +/qapi/qapi-types-common.[ch] +/qapi/qapi-types-crypto.[ch] +/qapi/qapi-types-introspect.[ch] +/qapi/qapi-types-migration.[ch] +/qapi/qapi-types-misc.[ch] +/qapi/qapi-types-net.[ch] +/qapi/qapi-types-rocker.[ch] +/qapi/qapi-types-run-state.[ch] +/qapi/qapi-types-sockets.[ch] +/qapi/qapi-types-tpm.[ch] +/qapi/qapi-types-trace.[ch] +/qapi/qapi-types-transaction.[ch] +/qapi/qapi-types-ui.[ch] +/qapi/qapi-types.[ch] +/qapi/qapi-visit-block-core.[ch] +/qapi/qapi-visit-block.[ch] +/qapi/qapi-visit-char.[ch] +/qapi/qapi-visit-common.[ch] +/qapi/qapi-visit-crypto.[ch] +/qapi/qapi-visit-introspect.[ch] +/qapi/qapi-visit-migration.[ch] +/qapi/qapi-visit-misc.[ch] +/qapi/qapi-visit-net.[ch] +/qapi/qapi-visit-rocker.[ch] +/qapi/qapi-visit-run-state.[ch] +/qapi/qapi-visit-sockets.[ch] +/qapi/qapi-visit-tpm.[ch] +/qapi/qapi-visit-trace.[ch] +/qapi/qapi-visit-transaction.[ch] +/qapi/qapi-visit-ui.[ch] +/qapi/qapi-visit.[ch] +/qapi/qapi-doc.texi /qemu-doc.html /qemu-doc.info /qemu-doc.txt @@ -90,10 +90,78 @@ endif include $(SRC_PATH)/rules.mak GENERATED_FILES = qemu-version.h config-host.h qemu-options.def -GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h -GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c -GENERATED_FILES += qmp-introspect.h -GENERATED_FILES += qmp-introspect.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 +GENERATED_FILES += qapi/qapi-types-common.h qapi/qapi-types-common.c +GENERATED_FILES += qapi/qapi-types-crypto.h qapi/qapi-types-crypto.c +GENERATED_FILES += qapi/qapi-types-introspect.h qapi/qapi-types-introspect.c +GENERATED_FILES += qapi/qapi-types-migration.h qapi/qapi-types-migration.c +GENERATED_FILES += qapi/qapi-types-misc.h qapi/qapi-types-misc.c +GENERATED_FILES += qapi/qapi-types-net.h qapi/qapi-types-net.c +GENERATED_FILES += qapi/qapi-types-rocker.h qapi/qapi-types-rocker.c +GENERATED_FILES += qapi/qapi-types-run-state.h qapi/qapi-types-run-state.c +GENERATED_FILES += qapi/qapi-types-sockets.h qapi/qapi-types-sockets.c +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/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 +GENERATED_FILES += qapi/qapi-visit-common.h qapi/qapi-visit-common.c +GENERATED_FILES += qapi/qapi-visit-crypto.h qapi/qapi-visit-crypto.c +GENERATED_FILES += qapi/qapi-visit-introspect.h qapi/qapi-visit-introspect.c +GENERATED_FILES += qapi/qapi-visit-migration.h qapi/qapi-visit-migration.c +GENERATED_FILES += qapi/qapi-visit-misc.h qapi/qapi-visit-misc.c +GENERATED_FILES += qapi/qapi-visit-net.h qapi/qapi-visit-net.c +GENERATED_FILES += qapi/qapi-visit-rocker.h qapi/qapi-visit-rocker.c +GENERATED_FILES += qapi/qapi-visit-run-state.h qapi/qapi-visit-run-state.c +GENERATED_FILES += qapi/qapi-visit-sockets.h qapi/qapi-visit-sockets.c +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 += 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 +GENERATED_FILES += qapi/qapi-commands-common.h qapi/qapi-commands-common.c +GENERATED_FILES += qapi/qapi-commands-crypto.h qapi/qapi-commands-crypto.c +GENERATED_FILES += qapi/qapi-commands-introspect.h qapi/qapi-commands-introspect.c +GENERATED_FILES += qapi/qapi-commands-migration.h qapi/qapi-commands-migration.c +GENERATED_FILES += qapi/qapi-commands-misc.h qapi/qapi-commands-misc.c +GENERATED_FILES += qapi/qapi-commands-net.h qapi/qapi-commands-net.c +GENERATED_FILES += qapi/qapi-commands-rocker.h qapi/qapi-commands-rocker.c +GENERATED_FILES += qapi/qapi-commands-run-state.h qapi/qapi-commands-run-state.c +GENERATED_FILES += qapi/qapi-commands-sockets.h qapi/qapi-commands-sockets.c +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/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 +GENERATED_FILES += qapi/qapi-events-common.h qapi/qapi-events-common.c +GENERATED_FILES += qapi/qapi-events-crypto.h qapi/qapi-events-crypto.c +GENERATED_FILES += qapi/qapi-events-introspect.h qapi/qapi-events-introspect.c +GENERATED_FILES += qapi/qapi-events-migration.h qapi/qapi-events-migration.c +GENERATED_FILES += qapi/qapi-events-misc.h qapi/qapi-events-misc.c +GENERATED_FILES += qapi/qapi-events-net.h qapi/qapi-events-net.c +GENERATED_FILES += qapi/qapi-events-rocker.h qapi/qapi-events-rocker.c +GENERATED_FILES += qapi/qapi-events-run-state.h qapi/qapi-events-run-state.c +GENERATED_FILES += qapi/qapi-events-sockets.h qapi/qapi-events-sockets.c +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 += qapi/qapi-introspect.c qapi/qapi-introspect.h +GENERATED_FILES += qapi/qapi-doc.texi GENERATED_FILES += trace/generated-tcg-tracers.h @@ -482,32 +550,34 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS) qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS) -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) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-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) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-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) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \ - "GEN","$@") - -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ +qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \ +$(SRC_PATH)/scripts/qapi/events.py \ +$(SRC_PATH)/scripts/qapi/introspect.py \ +$(SRC_PATH)/scripts/qapi/types.py \ +$(SRC_PATH)/scripts/qapi/visit.py \ +$(SRC_PATH)/scripts/qapi/common.py \ +$(SRC_PATH)/scripts/qapi/doc.py \ +$(SRC_PATH)/scripts/ordereddict.py \ +$(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-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) + $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-gen.py \ + -o qga/qapi-generated -p "qga-" $<, \ + "GEN","$(@:%-timestamp=%)") + @>$@ + +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 \ $(SRC_PATH)/qapi/introspect.json \ $(SRC_PATH)/qapi/migration.json \ + $(SRC_PATH)/qapi/misc.json \ $(SRC_PATH)/qapi/net.json \ $(SRC_PATH)/qapi/rocker.json \ $(SRC_PATH)/qapi/run-state.json \ @@ -517,33 +587,86 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ $(SRC_PATH)/qapi/transaction.json \ $(SRC_PATH)/qapi/ui.json -qapi-types.c qapi-types.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o "." -b $<, \ - "GEN","$@") -qapi-visit.c qapi-visit.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o "." -b $<, \ - "GEN","$@") -qapi-event.c qapi-event.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") -qmp-commands.h qmp-marshal.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") -qmp-introspect.h qmp-introspect.c :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o "." $<, \ - "GEN","$@") - -QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.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 \ +qapi/qapi-types-common.c qapi/qapi-types-common.h \ +qapi/qapi-types-crypto.c qapi/qapi-types-crypto.h \ +qapi/qapi-types-introspect.c qapi/qapi-types-introspect.h \ +qapi/qapi-types-migration.c qapi/qapi-types-migration.h \ +qapi/qapi-types-misc.c qapi/qapi-types-misc.h \ +qapi/qapi-types-net.c qapi/qapi-types-net.h \ +qapi/qapi-types-rocker.c qapi/qapi-types-rocker.h \ +qapi/qapi-types-run-state.c qapi/qapi-types-run-state.h \ +qapi/qapi-types-sockets.c qapi/qapi-types-sockets.h \ +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/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 \ +qapi/qapi-visit-common.c qapi/qapi-visit-common.h \ +qapi/qapi-visit-crypto.c qapi/qapi-visit-crypto.h \ +qapi/qapi-visit-introspect.c qapi/qapi-visit-introspect.h \ +qapi/qapi-visit-migration.c qapi/qapi-visit-migration.h \ +qapi/qapi-visit-misc.c qapi/qapi-visit-misc.h \ +qapi/qapi-visit-net.c qapi/qapi-visit-net.h \ +qapi/qapi-visit-rocker.c qapi/qapi-visit-rocker.h \ +qapi/qapi-visit-run-state.c qapi/qapi-visit-run-state.h \ +qapi/qapi-visit-sockets.c qapi/qapi-visit-sockets.h \ +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 \ +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 \ +qapi/qapi-commands-common.c qapi/qapi-commands-common.h \ +qapi/qapi-commands-crypto.c qapi/qapi-commands-crypto.h \ +qapi/qapi-commands-introspect.c qapi/qapi-commands-introspect.h \ +qapi/qapi-commands-migration.c qapi/qapi-commands-migration.h \ +qapi/qapi-commands-misc.c qapi/qapi-commands-misc.h \ +qapi/qapi-commands-net.c qapi/qapi-commands-net.h \ +qapi/qapi-commands-rocker.c qapi/qapi-commands-rocker.h \ +qapi/qapi-commands-run-state.c qapi/qapi-commands-run-state.h \ +qapi/qapi-commands-sockets.c qapi/qapi-commands-sockets.h \ +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/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 \ +qapi/qapi-events-common.c qapi/qapi-events-common.h \ +qapi/qapi-events-crypto.c qapi/qapi-events-crypto.h \ +qapi/qapi-events-introspect.c qapi/qapi-events-introspect.h \ +qapi/qapi-events-migration.c qapi/qapi-events-migration.h \ +qapi/qapi-events-misc.c qapi/qapi-events-misc.h \ +qapi/qapi-events-net.c qapi/qapi-events-net.h \ +qapi/qapi-events-rocker.c qapi/qapi-events-rocker.h \ +qapi/qapi-events-run-state.c qapi/qapi-events-run-state.h \ +qapi/qapi-events-sockets.c qapi/qapi-events-sockets.h \ +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 \ +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 "qapi" -b $<, \ + "GEN","$(@:%-timestamp=%)") + @>$@ + +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) @@ -601,7 +724,7 @@ clean: rm -f trace/generated-tracers-dtrace.dtrace* rm -f trace/generated-tracers-dtrace.h* rm -f $(foreach f,$(GENERATED_FILES),$(f) $(f)-timestamp) - rm -rf qapi-generated + rm -f qapi-gen-timestamp rm -rf qga/qapi-generated for d in $(ALL_SUBDIRS); do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ @@ -809,13 +932,11 @@ 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 docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py) +docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi + @cp -p $< $@ -docs/interop/qemu-qmp-qapi.texi: $(qapi-modules) - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") - -docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json - $(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") +docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi + @cp -p $< $@ qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi qemu.1: qemu-option-trace.texi diff --git a/Makefile.objs b/Makefile.objs index 5dc134818c..d741134cc7 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -2,7 +2,60 @@ # 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/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 +util-obj-y += qapi/qapi-types-common.o +util-obj-y += qapi/qapi-types-crypto.o +util-obj-y += qapi/qapi-types-introspect.o +util-obj-y += qapi/qapi-types-migration.o +util-obj-y += qapi/qapi-types-misc.o +util-obj-y += qapi/qapi-types-net.o +util-obj-y += qapi/qapi-types-rocker.o +util-obj-y += qapi/qapi-types-run-state.o +util-obj-y += qapi/qapi-types-sockets.o +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/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 +util-obj-y += qapi/qapi-visit-common.o +util-obj-y += qapi/qapi-visit-crypto.o +util-obj-y += qapi/qapi-visit-introspect.o +util-obj-y += qapi/qapi-visit-migration.o +util-obj-y += qapi/qapi-visit-misc.o +util-obj-y += qapi/qapi-visit-net.o +util-obj-y += qapi/qapi-visit-rocker.o +util-obj-y += qapi/qapi-visit-run-state.o +util-obj-y += qapi/qapi-visit-sockets.o +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/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 +util-obj-y += qapi/qapi-events-common.o +util-obj-y += qapi/qapi-events-crypto.o +util-obj-y += qapi/qapi-events-introspect.o +util-obj-y += qapi/qapi-events-migration.o +util-obj-y += qapi/qapi-events-misc.o +util-obj-y += qapi/qapi-events-net.o +util-obj-y += qapi/qapi-events-rocker.o +util-obj-y += qapi/qapi-events-run-state.o +util-obj-y += qapi/qapi-events-sockets.o +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 += qapi/qapi-introspect.o chardev-obj-y = chardev/ @@ -78,8 +131,24 @@ common-obj-$(CONFIG_FDT) += device_tree.o ###################################################################### # qapi -common-obj-y += qmp-marshal.o -common-obj-y += qmp-introspect.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 +common-obj-y += qapi/qapi-commands-common.o +common-obj-y += qapi/qapi-commands-crypto.o +common-obj-y += qapi/qapi-commands-introspect.o +common-obj-y += qapi/qapi-commands-migration.o +common-obj-y += qapi/qapi-commands-misc.o +common-obj-y += qapi/qapi-commands-net.o +common-obj-y += qapi/qapi-commands-rocker.o +common-obj-y += qapi/qapi-commands-run-state.o +common-obj-y += qapi/qapi-commands-sockets.o +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 += qapi/qapi-introspect.o common-obj-y += qmp.o hmp.o endif @@ -102,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/ diff --git a/arch_init.c b/arch_init.c index 4c36f2b076..46d03f550d 100644 --- a/arch_init.c +++ b/arch_init.c @@ -28,9 +28,9 @@ #include "sysemu/arch_init.h" #include "hw/pci/pci.h" #include "hw/audio/soundhw.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "qmp-commands.h" #include "hw/acpi/acpi.h" #include "qemu/help_option.h" diff --git a/backends/cryptodev.c b/backends/cryptodev.c index d0dff1a463..f35be377ef 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -26,7 +26,6 @@ #include "hw/boards.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qapi-visit.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" #include "hw/virtio/virtio-crypto.h" diff --git a/backends/hostmem.c b/backends/hostmem.c index 8aa0412032..f61093654e 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -9,12 +9,13 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ + #include "qemu/osdep.h" #include "sysemu/hostmem.h" #include "hw/boards.h" #include "qapi/error.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/visitor.h" -#include "qapi-visit.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" @@ -30,8 +30,8 @@ #include "sysemu/kvm.h" #include "sysemu/balloon.h" #include "trace-root.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qerror.h" static QEMUBalloonEvent *balloon_event_fn; @@ -32,7 +32,6 @@ #include "qemu/module.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qstring.h" #include "sysemu/block-backend.h" @@ -42,7 +41,6 @@ #include "qemu/coroutine.h" #include "block/qapi.h" #include "qemu/timer.h" -#include "qapi-event.h" #include "qemu/cutils.h" #include "qemu/id.h" diff --git a/block/block-backend.c b/block/block-backend.c index 0266ac990b..94ffbb6a60 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -17,8 +17,8 @@ #include "block/throttle-groups.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" -#include "qapi-event.h" #include "qapi/error.h" +#include "qapi/qapi-events-block.h" #include "qemu/id.h" #include "qemu/option.h" #include "trace.h" diff --git a/block/crypto.c b/block/crypto.c index 3df66947c5..aeac482e7b 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -24,9 +24,9 @@ #include "sysemu/block-backend.h" #include "crypto/block.h" #include "qapi/opts-visitor.h" +#include "qapi/qapi-visit-crypto.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-input-visitor.h" -#include "qapi-visit.h" #include "qapi/error.h" #include "qemu/option.h" #include "block/crypto.h" diff --git a/block/iscsi.c b/block/iscsi.c index 421983dd6f..d2b320ea41 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -37,8 +37,8 @@ #include "qemu/iov.h" #include "qemu/option.h" #include "qemu/uuid.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "crypto/secret.h" diff --git a/block/nbd.c b/block/nbd.c index 69b5fd5e8f..d4e4172c08 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -33,7 +33,7 @@ #include "block/block_int.h" #include "qemu/module.h" #include "qemu/option.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-sockets.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qdict.h" diff --git a/block/nfs.c b/block/nfs.c index 6576a73d6e..bbdb4fadad 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -35,9 +35,9 @@ #include "qemu/uri.h" #include "qemu/cutils.h" #include "sysemu/sysemu.h" +#include "qapi/qapi-visit-block-core.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -#include "qapi-visit.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include <nfsc/libnfs.h> diff --git a/block/qapi.c b/block/qapi.c index 1fdeb1ef2f..4c9923d262 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -27,10 +27,10 @@ #include "block/block_int.h" #include "block/throttle-groups.h" #include "block/write-threshold.h" -#include "qmp-commands.h" -#include "qapi-visit.h" #include "qapi/error.h" +#include "qapi/qapi-commands-block-core.h" #include "qapi/qobject-output-visitor.h" +#include "qapi/qapi-visit-block-core.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" diff --git a/block/qcow2.c b/block/qcow2.c index 57a517e2bd..3dd098b74f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -30,16 +30,14 @@ #include "block/qcow2.h" #include "qemu/error-report.h" #include "qapi/error.h" -#include "qapi/qmp/qerror.h" +#include "qapi/qapi-events-block-core.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -#include "qapi-event.h" #include "trace.h" #include "qemu/option_int.h" #include "qemu/cutils.h" #include "qemu/bswap.h" #include "qapi/opts-visitor.h" -#include "qapi-visit.h" #include "block/crypto.h" /* diff --git a/block/quorum.c b/block/quorum.c index 19f1c34425..14333c18aa 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -18,11 +18,11 @@ #include "qemu/option.h" #include "block/block_int.h" #include "qapi/error.h" +#include "qapi/qapi-events-block.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" -#include "qapi-event.h" #include "crypto/hash.h" #define HASH_LENGTH 32 diff --git a/block/sheepdog.c b/block/sheepdog.c index ac02b10fe0..215223053b 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -13,8 +13,8 @@ */ #include "qemu/osdep.h" -#include "qapi-visit.h" #include "qapi/error.h" +#include "qapi/qapi-visit-sockets.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-input-visitor.h" #include "qemu/uri.h" diff --git a/block/ssh.c b/block/ssh.c index b63addcf94..b11d4c5e86 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -34,7 +34,7 @@ #include "qemu/cutils.h" #include "qemu/sockets.h" #include "qemu/uri.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-sockets.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" diff --git a/block/throttle-groups.c b/block/throttle-groups.c index f26bcb5eee..36cc0430c3 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -30,7 +30,7 @@ #include "qemu/thread.h" #include "sysemu/qtest.h" #include "qapi/error.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-block-core.h" #include "qom/object.h" #include "qom/object_interfaces.h" diff --git a/block/write-threshold.c b/block/write-threshold.c index db3de0fa6d..1d48fc2077 100644 --- a/block/write-threshold.c +++ b/block/write-threshold.c @@ -15,9 +15,9 @@ #include "qemu/coroutine.h" #include "block/write-threshold.h" #include "qemu/notify.h" -#include "qapi-event.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-events-block-core.h" uint64_t bdrv_write_threshold_get(const BlockDriverState *bs) { diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 3a5479bdad..65a84739ed 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -14,8 +14,8 @@ #include "sysemu/block-backend.h" #include "hw/block/block.h" #include "qapi/error.h" +#include "qapi/qapi-commands-block.h" #include "sysemu/sysemu.h" -#include "qmp-commands.h" #include "block/nbd.h" #include "io/channel-socket.h" #include "io/net-listener.h" diff --git a/blockdev.c b/blockdev.c index 3fb1ca803c..1fbfd3a2c4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -40,10 +40,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/config-file.h" +#include "qapi/qapi-commands-block.h" +#include "qapi/qapi-commands-transaction.h" +#include "qapi/qapi-visit-block-core.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" -#include "qapi-visit.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qlist.h" @@ -51,7 +53,6 @@ #include "sysemu/sysemu.h" #include "sysemu/iothread.h" #include "block/block_int.h" -#include "qmp-commands.h" #include "block/trace.h" #include "sysemu/arch_init.h" #include "sysemu/qtest.h" diff --git a/blockjob.c b/blockjob.c index 3f52f29f75..801d29d849 100644 --- a/blockjob.c +++ b/blockjob.c @@ -30,11 +30,11 @@ #include "block/block_int.h" #include "sysemu/block-backend.h" #include "qapi/error.h" +#include "qapi/qapi-events-block-core.h" #include "qapi/qmp/qerror.h" #include "qemu/coroutine.h" #include "qemu/id.h" #include "qemu/timer.h" -#include "qapi-event.h" /* Right now, this mutex is only needed to synchronize accesses to job->busy * and job->sleep_timer, such as concurrent calls to block_job_do_yield and diff --git a/chardev/char-fe.c b/chardev/char-fe.c index c611b3fa3e..392db78b13 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -24,7 +24,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qapi/error.h" -#include "qapi-visit.h" +#include "qapi/qmp/qerror.h" #include "sysemu/replay.h" #include "chardev/char-fe.h" diff --git a/chardev/char-ringbuf.c b/chardev/char-ringbuf.c index 679afaa4fd..87832e2792 100644 --- a/chardev/char-ringbuf.c +++ b/chardev/char-ringbuf.c @@ -24,8 +24,8 @@ #include "qemu/osdep.h" #include "chardev/char.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-char.h" #include "qemu/base64.h" #include "qemu/option.h" diff --git a/chardev/char-socket.c b/chardev/char-socket.c index bdd6cff5f6..22f65971a1 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -31,6 +31,7 @@ #include "qemu/option.h" #include "qapi/error.h" #include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-sockets.h" #include "chardev/char-io.h" diff --git a/chardev/char.c b/chardev/char.c index 01d979a1da..5d7b079ef0 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -29,9 +29,9 @@ #include "qemu/config-file.h" #include "qemu/error-report.h" #include "chardev/char.h" -#include "qmp-commands.h" -#include "qapi-visit.h" #include "qapi/error.h" +#include "qapi/qapi-commands-char.h" +#include "qapi/qmp/qerror.h" #include "sysemu/replay.h" #include "qemu/help_option.h" #include "qemu/option.h" @@ -7053,7 +7053,6 @@ DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-sche DIRS="$DIRS docs docs/interop fsdev scsi" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" DIRS="$DIRS roms/seabios roms/vgabios" -DIRS="$DIRS qapi-generated" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" @@ -27,6 +27,8 @@ #include "cpu.h" #include "monitor/monitor.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-events-run-state.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" @@ -38,7 +40,6 @@ #include "sysemu/hax.h" #include "sysemu/hvf.h" #include "sysemu/whpx.h" -#include "qmp-commands.h" #include "exec/exec-all.h" #include "qemu/thread.h" @@ -49,7 +50,6 @@ #include "qemu/bitmap.h" #include "qemu/seqlock.h" #include "tcg.h" -#include "qapi-event.h" #include "hw/nmi.h" #include "sysemu/replay.h" #include "hw/boards.h" diff --git a/crypto/cipherpriv.h b/crypto/cipherpriv.h index 77da4c2f32..0823239f41 100644 --- a/crypto/cipherpriv.h +++ b/crypto/cipherpriv.h @@ -15,7 +15,7 @@ #ifndef QCRYPTO_CIPHERPRIV_H #define QCRYPTO_CIPHERPRIV_H -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" typedef struct QCryptoCipherDriver QCryptoCipherDriver; diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 5900b39b91..25b7180a18 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -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: @@ -899,12 +899,13 @@ the names of built-in types. Clients should examine member == Code generation == -Schemas are fed into five scripts to generate all the code/files that, -paired with the core QAPI libraries, comprise everything required to -take JSON commands read in by a Client JSON Protocol server, unmarshal -the arguments into the underlying C types, call into the corresponding -C function, map the response back to a Client JSON Protocol response -to be returned to the user, and introspect the commands. +The QAPI code generator qapi-gen.py generates code and documentation +from the schema. Together with the core QAPI libraries, this code +provides everything required to take JSON commands read in by a Client +JSON Protocol server, unmarshal the arguments into the underlying C +types, call into the corresponding C function, map the response back +to a Client JSON Protocol response to be returned to the user, and +introspect the commands. As an example, we'll use the following schema, which describes a single complex user-defined type, along with command which takes a @@ -922,18 +923,23 @@ qmp_my_command(); everything else is produced by the generator. { 'event': 'MY_EVENT' } +We run qapi-gen.py like this: + + $ python scripts/qapi-gen.py --output-dir="qapi-generated" \ + --prefix="example-" example-schema.json + For a more thorough look at generated code, the testsuite includes tests/qapi-schema/qapi-schema-tests.json that covers more examples of what the generator will accept, and compiles the resulting C code as part of 'make check-unit'. -=== scripts/qapi-types.py === +=== Code generated for QAPI types === -Used to generate the C types defined by a schema, along with -supporting code. The following files are created: +The following files are created: $(prefix)qapi-types.h - C types corresponding to types defined in - the schema you pass in + the schema + $(prefix)qapi-types.c - Cleanup functions for the above C types The $(prefix) is an optional parameter used as a namespace to keep the @@ -943,8 +949,6 @@ created code. Example: - $ python scripts/qapi-types.py --output-dir="qapi-generated" \ - --prefix="example-" example-schema.json $ cat qapi-generated/example-qapi-types.h [Uninteresting stuff omitted...] @@ -1008,28 +1012,26 @@ Example: visit_free(v); } -=== scripts/qapi-visit.py === +=== Code generated for visiting QAPI types === -Used to generate the visitor functions used to walk through and -convert between a native QAPI C data structure and some other format -(such as QObject); the generated functions are named visit_type_FOO() -and visit_type_FOO_members(). +These are the visitor functions used to walk through and convert +between a native QAPI C data structure and some other format (such as +QObject); the generated functions are named visit_type_FOO() and +visit_type_FOO_members(). The following files are generated: -$(prefix)qapi-visit.c: visitor function for a particular C type, used +$(prefix)qapi-visit.c: Visitor function for a particular C type, used to automagically convert QObjects into the corresponding C type and vice-versa, as well as for deallocating memory for an existing C type -$(prefix)qapi-visit.h: declarations for previously mentioned visitor +$(prefix)qapi-visit.h: Declarations for previously mentioned visitor functions Example: - $ python scripts/qapi-visit.py --output-dir="qapi-generated" - --prefix="example-" example-schema.json $ cat qapi-generated/example-qapi-visit.h [Uninteresting stuff omitted...] @@ -1137,31 +1139,23 @@ Example: error_propagate(errp, err); } -=== scripts/qapi-commands.py === +=== Code generated for commands === + +These are the marshaling/dispatch functions for the commands defined +in the schema. The generated code provides qmp_marshal_COMMAND(), and +declares qmp_COMMAND() that the user must implement. -Used to generate the marshaling/dispatch functions for the commands -defined in the schema. The generated code implements -qmp_marshal_COMMAND() (registered automatically), and declares -qmp_COMMAND() that the user must implement. The following files are -generated: +The following files are generated: -$(prefix)qmp-marshal.c: command marshal/dispatch functions for each - QMP command defined in the schema. Functions - generated by qapi-visit.py are used to - convert QObjects received from the wire into - function parameters, and uses the same - visitor functions to convert native C return - values to QObjects from transmission back - over the wire. +$(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: - $ python scripts/qapi-commands.py --output-dir="qapi-generated" - --prefix="example-" example-schema.json - $ cat qapi-generated/example-qmp-commands.h + $ cat qapi-generated/example-qapi-commands.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QMP_COMMANDS_H @@ -1176,7 +1170,7 @@ Example: void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp); #endif - $ cat qapi-generated/example-qmp-marshal.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) @@ -1242,21 +1236,21 @@ Example: qmp_marshal_my_command, QCO_NO_OPTIONS); } -=== scripts/qapi-event.py === +=== Code generated for events === -Used to generate the event-related C code defined by a schema, with -implementations for qapi_event_send_FOO(). The following files are -created: +This is the code related to events defined in the schema, providing +qapi_event_send_EVENT(). -$(prefix)qapi-event.h - Function prototypes for each event type, plus an +The following files are created: + +$(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: - $ python scripts/qapi-event.py --output-dir="qapi-generated" - --prefix="example-" example-schema.json - $ cat qapi-generated/example-qapi-event.h + $ cat qapi-generated/example-qapi-events.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QAPI_EVENT_H @@ -1279,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) @@ -1301,25 +1295,25 @@ Example: QDECREF(qmp); } - const char *const example_QAPIEvent_lookup[] = { - [EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT", - [EXAMPLE_QAPI_EVENT__MAX] = NULL, + const QEnumLookup example_QAPIEvent_lookup = { + .array = (const char *const[]) { + [EXAMPLE_QAPI_EVENT_MY_EVENT] = "MY_EVENT", + }, + .size = EXAMPLE_QAPI_EVENT__MAX }; -=== scripts/qapi-introspect.py === +=== Code generated for introspection === + +The following files are created: -Used to generate the introspection C code for a schema. The following -files are created: +$(prefix)qapi-introspect.c - Defines a string holding a JSON + description of the schema -$(prefix)qmp-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: - $ python scripts/qapi-introspect.py --output-dir="qapi-generated" - --prefix="example-" example-schema.json - $ cat qapi-generated/example-qmp-introspect.h + $ cat qapi-generated/example-qapi-introspect.h [Uninteresting stuff omitted...] #ifndef EXAMPLE_QMP_INTROSPECT_H @@ -1328,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[] = "[" diff --git a/docs/devel/writing-qmp-commands.txt b/docs/devel/writing-qmp-commands.txt index 4f5b24c0c4..9dfc62bf5a 100644 --- a/docs/devel/writing-qmp-commands.txt +++ b/docs/devel/writing-qmp-commands.txt @@ -15,8 +15,8 @@ start with docs/interop/qmp-intro.txt. Generally speaking, the following steps should be taken in order to write a new QMP command. -1. Write the command's and type(s) specification in the QAPI schema file - (qapi-schema.json in the root source directory) +1. Define the command and any types it needs in the appropriate QAPI + schema module. 2. Write the QMP command itself, which is a regular C function. Preferably, the command should be exported by some QEMU subsystem. But it can also be @@ -36,9 +36,9 @@ very simple and get more complex as we progress. For all the examples in the next sections, the test setup is the same and is shown here. -First, QEMU should be started as: +First, QEMU should be started like this: -# /path/to/your/source/qemu [...] \ +# qemu-system-TARGET [...] \ -chardev socket,id=qmp,port=4444,host=localhost,server \ -mon chardev=qmp,mode=control,pretty=on @@ -88,8 +88,9 @@ command carries some meaningful action in QEMU but here it will just print Our command will be called "hello-world". It takes no arguments, nor does it return any data. -The first step is to add the following line to the bottom of the -qapi-schema.json file: +The first step is defining the command in the appropriate QAPI schema +module. We pick module qapi/misc.json, and add the following line at +the bottom: { 'command': 'hello-world' } @@ -178,7 +179,7 @@ described in the "Testing" section and then send two commands: } } -You should see "Hello, world" and "we love qemu" in the terminal running qemu, +You should see "Hello, world" and "We love qemu" in the terminal running qemu, if you don't see these strings, then something went wrong. === Errors === @@ -220,32 +221,25 @@ The QMP server's response should be: } } -As a general rule, all QMP errors should use ERROR_CLASS_GENERIC_ERROR -(done by default when using error_setg()). There are two exceptions to -this rule: +Note that error_setg() produces a "GenericError" class. In general, +all QMP errors should have that error class. There are two exceptions +to this rule: - 1. A non-generic ErrorClass value exists* for the failure you want to report - (eg. DeviceNotFound) + 1. To support a management application's need to recognize a specific + error for special handling - 2. Management applications have to take special action on the failure you - want to report, hence you have to add a new ErrorClass value so that they - can check for it + 2. Backward compatibility If the failure you want to report falls into one of the two cases above, use error_set() with a second argument of an ErrorClass value. - * All existing ErrorClass values are defined in the qapi-schema.json file - === Command Documentation === There's only one step missing to make "hello-world"'s implementation complete, and that's its documentation in the schema file. -This is very important. No QMP command will be accepted in QEMU without proper -documentation. - There are many examples of such documentation in the schema file already, but -here goes "hello-world"'s new entry for the qapi-schema.json file: +here goes "hello-world"'s new entry for qapi/misc.json: ## # @hello-world @@ -425,8 +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 the "qmp-commands.h" header file in qemu-timer.c, - otherwise qemu won't build +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: diff --git a/docs/interop/qmp-intro.txt b/docs/interop/qmp-intro.txt index adbc94abb1..900d69d612 100644 --- a/docs/interop/qmp-intro.txt +++ b/docs/interop/qmp-intro.txt @@ -78,7 +78,8 @@ Escape character is '^]'. } } -Please, refer to the qapi-schema.json file for a complete command reference. +Please refer to docs/interop/qemu-qmp-ref.* for a complete command +reference, generated from qapi/qapi-schema.json. QMP wiki page ------------- diff --git a/docs/xen-save-devices-state.txt b/docs/xen-save-devices-state.txt index a72ecc8081..1912ecad25 100644 --- a/docs/xen-save-devices-state.txt +++ b/docs/xen-save-devices-state.txt @@ -8,8 +8,7 @@ These operations are normally used with migration (see migration.txt), however it is also possible to save the state of all devices to file, without saving the RAM or the block devices of the VM. -This operation is called "xen-save-devices-state" (see -qmp-commands.txt) +The save operation is available as QMP command xen-save-devices-state. The binary format used in the file is the following: @@ -23,9 +23,9 @@ #include "sysemu/memory_mapping.h" #include "sysemu/cpus.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-events-misc.h" #include "qapi/qmp/qerror.h" -#include "qmp-commands.h" -#include "qapi-event.h" #include "qemu/error-report.h" #include "hw/misc/vmcoreinfo.h" @@ -23,17 +23,25 @@ #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/timer.h" -#include "qmp-commands.h" #include "qemu/sockets.h" #include "monitor/monitor.h" #include "monitor/qdev.h" #include "qapi/error.h" #include "qapi/opts-visitor.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" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-net.h" +#include "qapi/qapi-commands-rocker.h" +#include "qapi/qapi-commands-run-state.h" +#include "qapi/qapi-commands-tpm.h" +#include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" -#include "qapi-visit.h" #include "qom/object_interfaces.h" #include "ui/console.h" #include "block/nbd.h" diff --git a/hw/acpi/core.c b/hw/acpi/core.c index b50b3ca772..b8d39012cd 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -27,8 +27,8 @@ #include "qemu/config-file.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" -#include "qapi-visit.h" -#include "qapi-event.h" +#include "qapi/qapi-events-run-state.h" +#include "qapi/qapi-visit-misc.h" #include "qemu/error-report.h" #include "qemu/option.h" diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index a233fe17cf..5ae595ecbe 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -2,7 +2,7 @@ #include "hw/boards.h" #include "hw/acpi/cpu.h" #include "qapi/error.h" -#include "qapi-event.h" +#include "qapi/qapi-events-misc.h" #include "trace.h" #include "sysemu/numa.h" diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index ea958a0e99..0ff1712c4c 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -5,8 +5,8 @@ #include "hw/boards.h" #include "hw/qdev-core.h" #include "trace.h" -#include "qapi-event.h" #include "qapi/error.h" +#include "qapi/qapi-events-misc.h" #define MEMORY_SLOTS_NUMBER "MDNR" #define MEMORY_HOTPLUG_IO_REGION "HPMR" diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c index f25eafc0ec..d78b579a20 100644 --- a/hw/acpi/vmgenid.c +++ b/hw/acpi/vmgenid.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands-misc.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/vmgenid.h" diff --git a/hw/block/block.c b/hw/block/block.c index b0269c857f..b91e2b6d7e 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -12,6 +12,7 @@ #include "sysemu/block-backend.h" #include "hw/block/block.h" #include "qapi/error.h" +#include "qapi/qapi-types-block.h" #include "qemu/error-report.h" void blkconf_serial(BlockConf *conf, char **serial) diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index 57ad5012a7..79384a2b0a 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -32,6 +32,7 @@ #include "qemu/osdep.h" #include "sysemu/block-backend.h" +#include "qapi/qapi-types-block.h" #include "qemu/bswap.h" #include "hw/block/block.h" #include "trace.h" diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 4be5d4ee52..679a824888 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -15,8 +15,8 @@ #include "qemu/error-report.h" #include "trace.h" #include "hw/virtio/virtio-serial.h" -#include "qapi-event.h" #include "qapi/error.h" +#include "qapi/qapi-events-char.h" #define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport" #define VIRTIO_CONSOLE(obj) \ diff --git a/hw/core/machine.c b/hw/core/machine.c index 5d445839e8..5e2bbcdace 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "hw/boards.h" #include "qapi/error.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-common.h" #include "qapi/visitor.h" #include "hw/sysbus.h" #include "sysemu/sysemu.h" diff --git a/hw/core/qdev.c b/hw/core/qdev.c index f3754ee606..f6f92473b8 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -29,6 +29,7 @@ #include "hw/qdev.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qapi/qapi-events-misc.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" #include "qemu/error-report.h" @@ -36,7 +37,6 @@ #include "hw/hotplug.h" #include "hw/boards.h" #include "hw/sysbus.h" -#include "qapi-event.h" bool qdev_hotplug = false; static bool qdev_hot_added = false; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 55e69d66fe..94cfd40ef2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -67,8 +67,8 @@ #include "acpi-build.h" #include "hw/mem/pc-dimm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-common.h" #include "qapi/visitor.h" -#include "qapi-visit.h" #include "qom/cpu.h" #include "hw/nmi.h" #include "hw/i386/intel_iommu.h" diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index bfdbe55580..f24b7d4923 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -16,8 +16,8 @@ #include "hw/i386/apic-msidef.h" #include "hw/xen/xen_common.h" #include "hw/xen/xen_backend.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/error-report.h" #include "qemu/range.h" #include "sysemu/xen-mapcache.h" diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c index adbbf6e4a6..9be281fd87 100644 --- a/hw/ipmi/ipmi.c +++ b/hw/ipmi/ipmi.c @@ -26,9 +26,9 @@ #include "hw/hw.h" #include "hw/ipmi/ipmi.h" #include "sysemu/sysemu.h" -#include "qmp-commands.h" #include "qom/object_interfaces.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/visitor.h" static uint32_t ipmi_current_uuid = 1; diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 61e677f92f..acb656b672 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -25,7 +25,6 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "qapi-visit.h" #include "hw/mem/nvdimm.h" static void nvdimm_get_label_size(Object *obj, Visitor *v, const char *name, diff --git a/hw/net/rocker/qmp-norocker.c b/hw/net/rocker/qmp-norocker.c index 94c1e480ae..0d60513c01 100644 --- a/hw/net/rocker/qmp-norocker.c +++ b/hw/net/rocker/qmp-norocker.c @@ -17,8 +17,8 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-rocker.h" #include "qapi/qmp/qerror.h" RockerSwitch *qmp_query_rocker(const char *name, Error **errp) diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index a2a76c2a74..c02cbefece 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -22,9 +22,9 @@ #include "net/net.h" #include "net/eth.h" #include "qapi/error.h" +#include "qapi/qapi-commands-rocker.h" #include "qemu/iov.h" #include "qemu/bitops.h" -#include "qmp-commands.h" #include "rocker.h" #include "rocker_hw.h" diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index 4b3c9847db..27b17c890f 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -16,7 +16,7 @@ #include "qemu/osdep.h" #include "net/clients.h" - +#include "qapi/qapi-types-rocker.h" #include "rocker.h" #include "rocker_hw.h" #include "rocker_fp.h" diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index 9339df2d09..60046720a5 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -17,9 +17,9 @@ #include "qemu/osdep.h" #include "net/eth.h" #include "qapi/error.h" +#include "qapi/qapi-commands-rocker.h" #include "qemu/iov.h" #include "qemu/timer.h" -#include "qmp-commands.h" #include "rocker.h" #include "rocker_hw.h" diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 369d40b378..188744e17d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -23,7 +23,7 @@ #include "net/vhost_net.h" #include "hw/virtio/virtio-bus.h" #include "qapi/error.h" -#include "qapi-event.h" +#include "qapi/qapi-events-net.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index 74ce7316da..b941a0e842 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -22,9 +22,9 @@ #include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qerror.h" #include "hw/pci/pci.h" -#include "qmp-commands.h" #include "hw/pci/msi.h" bool msi_nonbroken; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e006b6ac71..2174c254eb 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -34,7 +34,6 @@ #include "hw/loader.h" #include "qemu/error-report.h" #include "qemu/range.h" -#include "qmp-commands.h" #include "trace.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" @@ -42,6 +41,7 @@ #include "hw/hotplug.h" #include "hw/boards.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/cutils.h" //#define DEBUG_PCI diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 4bb939d3d1..0ec5fa4cfe 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -38,7 +38,6 @@ #include "hw/ppc/spapr_vio.h" #include "hw/ppc/spapr_rtas.h" #include "hw/ppc/ppc.h" -#include "qapi-event.h" #include "hw/boards.h" #include <libfdt.h> diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c index cfdb274bfd..a37360537e 100644 --- a/hw/ppc/spapr_rtc.c +++ b/hw/ppc/spapr_rtc.c @@ -30,8 +30,8 @@ #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "hw/ppc/spapr.h" -#include "qapi-event.h" #include "qapi/error.h" +#include "qapi/qapi-events-misc.h" #include "qemu/cutils.h" void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns) diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index bdb6c18a0f..76241c240e 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -11,9 +11,9 @@ #include "qemu/osdep.h" #include "hw/boards.h" -#include "qmp-commands.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 9d93a16e0f..6f1f723b1f 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -31,9 +31,9 @@ #include "sysemu/replay.h" #include "hw/timer/mc146818rtc.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" -#include "qapi-event.h" -#include "qmp-commands.h" #ifdef TARGET_I386 #include "hw/i386/apic.h" diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index b787aee13b..f187a72c10 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -38,6 +38,7 @@ #include "migration/blocker.h" #include "qapi/error.h" #include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-tpm.h" #include "chardev/char-fe.h" #define DEBUG_TPM 0 diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index a495fe07f4..211df3191c 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -30,6 +30,7 @@ #include "tpm_int.h" #include "hw/hw.h" #include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-tpm.h" #include "tpm_util.h" #define DEBUG_TPM 0 diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 48224493a0..f456cea2e7 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -24,8 +24,8 @@ #include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "qapi/error.h" +#include "qapi/qapi-events-misc.h" #include "qapi/visitor.h" -#include "qapi-event.h" #include "trace.h" #include "qemu/error-report.h" diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index 98a5dd6689..6e8ba061d8 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -24,12 +24,12 @@ #include "qemu/config-file.h" #include "qemu/queue.h" #include "qapi/error.h" +#include "qapi/qapi-commands-run-state.h" +#include "qapi/qapi-events-run-state.h" #include "sysemu/sysemu.h" #include "sysemu/watchdog.h" -#include "qapi-event.h" #include "hw/nmi.h" #include "qemu/help_option.h" -#include "qmp-commands.h" static WatchdogAction watchdog_action = WATCHDOG_ACTION_RESET; static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; diff --git a/include/block/block.h b/include/block/block.h index 19b3ab9cb5..fac401ba3e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -2,7 +2,7 @@ #define BLOCK_H #include "block/aio.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/iov.h" #include "qemu/coroutine.h" #include "block/accounting.h" diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h index e3f4bbf51d..09efec609f 100644 --- a/include/block/dirty-bitmap.h +++ b/include/block/dirty-bitmap.h @@ -2,7 +2,7 @@ #define BLOCK_DIRTY_BITMAP_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/hbitmap.h" BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, diff --git a/include/block/nbd.h b/include/block/nbd.h index 495564c73a..2285637e67 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -20,7 +20,7 @@ #ifndef NBD_H #define NBD_H - +#include "qapi/qapi-types-block.h" #include "io/channel-socket.h" #include "crypto/tlscreds.h" diff --git a/include/chardev/char.h b/include/chardev/char.h index a381dc3df8..ebf1e0ba04 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -1,6 +1,7 @@ #ifndef QEMU_CHAR_H #define QEMU_CHAR_H +#include "qapi/qapi-types-char.h" #include "qemu/main-loop.h" #include "qemu/bitmap.h" #include "qom/object.h" diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 984fb8243f..bce2d4c8e4 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_CIPHER_H #define QCRYPTO_CIPHER_H -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" typedef struct QCryptoCipher QCryptoCipher; diff --git a/include/crypto/hash.h b/include/crypto/hash.h index ca3267f3df..077ac7bea0 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_HASH_H #define QCRYPTO_HASH_H -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h index 5e88905989..aa3c97a2ff 100644 --- a/include/crypto/hmac.h +++ b/include/crypto/hmac.h @@ -12,7 +12,7 @@ #ifndef QCRYPTO_HMAC_H #define QCRYPTO_HMAC_H -#include "qapi-types.h" +#include "qapi/qapi-types-crypto.h" typedef struct QCryptoHmac QCryptoHmac; struct QCryptoHmac { diff --git a/include/crypto/secret.h b/include/crypto/secret.h index 07a963e794..edd0e13236 100644 --- a/include/crypto/secret.h +++ b/include/crypto/secret.h @@ -21,6 +21,7 @@ #ifndef QCRYPTO_SECRET_H #define QCRYPTO_SECRET_H +#include "qapi/qapi-types-crypto.h" #include "qom/object.h" #define TYPE_QCRYPTO_SECRET "secret" diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h index ad47d88be7..6b011e1dbc 100644 --- a/include/crypto/tlscreds.h +++ b/include/crypto/tlscreds.h @@ -21,6 +21,7 @@ #ifndef QCRYPTO_TLSCREDS_H #define QCRYPTO_TLSCREDS_H +#include "qapi/qapi-types-crypto.h" #include "qom/object.h" #ifdef CONFIG_GNUTLS diff --git a/include/hw/block/block.h b/include/hw/block/block.h index f532d10e35..d4f4dfffab 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -12,7 +12,7 @@ #define HW_BLOCK_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" /* Configuration */ diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 68a0c904ea..3b813c7f7d 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -2,7 +2,7 @@ #define HW_FDC_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block.h" /* fdc.c */ #define MAX_FD 2 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index f8d9f5b231..f6ff32e7e2 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -14,6 +14,7 @@ #define HW_SPAPR_DRC_H #include <libfdt.h> +#include "qapi/qapi-types-run-state.h" #include "qom/object.h" #include "sysemu/sysemu.h" #include "hw/qdev.h" diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1d61a35108..b2ad8e9faa 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -1,6 +1,8 @@ #ifndef QEMU_QDEV_PROPERTIES_H #define QEMU_QDEV_PROPERTIES_H +#include "qapi/qapi-types-block.h" +#include "qapi/qapi-types-misc.h" #include "hw/qdev-core.h" /*** qdev-properties.c ***/ diff --git a/include/io/dns-resolver.h b/include/io/dns-resolver.h index 2f69c08c13..1a162185cc 100644 --- a/include/io/dns-resolver.h +++ b/include/io/dns-resolver.h @@ -22,6 +22,7 @@ #define QIO_DNS_RESOLVER_H #include "qemu-common.h" +#include "qapi/qapi-types-sockets.h" #include "qom/object.h" #include "io/task.h" diff --git a/include/migration/colo.h b/include/migration/colo.h index 50ace16205..2fe48ad353 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -14,7 +14,7 @@ #define QEMU_COLO_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-migration.h" void colo_info_init(void); diff --git a/include/migration/failover.h b/include/migration/failover.h index ad91ef2381..4c37218dcc 100644 --- a/include/migration/failover.h +++ b/include/migration/failover.h @@ -14,7 +14,7 @@ #define QEMU_FAILOVER_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-migration.h" void failover_init_state(void); FailoverStatus failover_set_state(FailoverStatus old_state, diff --git a/include/migration/global_state.h b/include/migration/global_state.h index d307de8350..fd22dd3034 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -13,6 +13,7 @@ #ifndef QEMU_MIGRATION_GLOBAL_STATE_H #define QEMU_MIGRATION_GLOBAL_STATE_H +#include "qapi/qapi-types-run-state.h" #include "sysemu/sysemu.h" void register_global_state(void); diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index ad64ad8e68..d1024d4bdc 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -3,6 +3,7 @@ #include "qemu-common.h" #include "block/block.h" +#include "qapi/qapi-types-misc.h" #include "qemu/readline.h" extern Monitor *cur_mon; diff --git a/include/net/filter.h b/include/net/filter.h index 0c4a2ea6c9..435acd6f82 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -9,6 +9,7 @@ #ifndef QEMU_NET_FILTER_H #define QEMU_NET_FILTER_H +#include "qapi/qapi-types-net.h" #include "qom/object.h" #include "qemu-common.h" #include "net/queue.h" diff --git a/include/net/net.h b/include/net/net.h index 3fc48e4f51..727643032c 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -2,7 +2,7 @@ #define QEMU_NET_H #include "qemu/queue.h" -#include "qapi-types.h" +#include "qapi/qapi-types-net.h" #include "net/queue.h" #include "migration/vmstate.h" diff --git a/include/qapi/clone-visitor.h b/include/qapi/clone-visitor.h index b119d3daa9..5b665ee38c 100644 --- a/include/qapi/clone-visitor.h +++ b/include/qapi/clone-visitor.h @@ -12,7 +12,6 @@ #define QAPI_CLONE_VISITOR_H #include "qapi/visitor.h" -#include "qapi-visit.h" /* * The clone visitor is for direct use only by the QAPI_CLONE() macro; diff --git a/include/qapi/error.h b/include/qapi/error.h index c2115a6a4a..bcb86a79f5 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -115,7 +115,7 @@ #ifndef ERROR_H #define ERROR_H -#include "qapi-types.h" +#include "qapi/qapi-types-common.h" /* * Overall category of an error. diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index 38ac68845c..012439a2e3 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -32,7 +32,7 @@ #ifndef QOBJECT_H #define QOBJECT_H -#include "qapi-types.h" +#include "qapi/qapi-builtin-types.h" struct QObject { QType type; diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index ecff296c11..5b2ed3f202 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -15,7 +15,7 @@ #ifndef QAPI_VISITOR_H #define QAPI_VISITOR_H -#include "qapi-types.h" +#include "qapi/qapi-builtin-types.h" /* * The QAPI schema defines both a set of C data types, and a QMP wire diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 8889bcb1ec..e88d4c37ab 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -9,7 +9,7 @@ int inet_aton(const char *cp, struct in_addr *ia); #endif /* !_WIN32 */ -#include "qapi-types.h" +#include "qapi/qapi-types-sockets.h" /* misc helpers */ int qemu_socket(int domain, int type, int protocol); diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 03d45f44f8..abeb886d93 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -26,7 +26,7 @@ #define THROTTLE_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/timer.h" #define THROTTLE_VALUE_MAX 1000000000000000LL diff --git a/include/qom/cpu.h b/include/qom/cpu.h index aff88fa16f..dc6d4956a8 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -24,6 +24,7 @@ #include "disas/bfd.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" +#include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" #include "qemu/queue.h" #include "qemu/thread.h" diff --git a/include/qom/object.h b/include/qom/object.h index dc73d59660..30db296af4 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -14,7 +14,7 @@ #ifndef QEMU_OBJECT_H #define QEMU_OBJECT_H -#include "qapi-types.h" +#include "qapi/qapi-builtin-types.h" #include "qemu/queue.h" struct TypeImpl; diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index d40d882e38..cecd494159 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -1,7 +1,7 @@ #ifndef QEMU_ARCH_INIT_H #define QEMU_ARCH_INIT_H -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" enum { QEMU_ARCH_ALL = -1, diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h index af49e19c78..66543ae8f4 100644 --- a/include/sysemu/balloon.h +++ b/include/sysemu/balloon.h @@ -14,7 +14,7 @@ #ifndef QEMU_BALLOON_H #define QEMU_BALLOON_H -#include "qapi-types.h" +#include "qapi/qapi-types-misc.h" typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index c14bcfe8c6..d824bc0941 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -14,6 +14,8 @@ #ifndef DUMP_H #define DUMP_H +#include "qapi/qapi-types-misc.h" + #define MAKEDUMPFILE_SIGNATURE "makedumpfile" #define MAX_SIZE_MDF_HEADER (4096) /* max size of makedumpfile_header */ #define TYPE_FLAT_HEADER (1) /* type of flattened format */ diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index d5ab0b99c6..47bc9846ac 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -14,6 +14,7 @@ #define SYSEMU_HOSTMEM_H #include "sysemu/sysemu.h" /* for MAX_NODES */ +#include "qapi/qapi-types-misc.h" #include "qom/object.h" #include "exec/memory.h" #include "qemu/bitmap.h" diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index dc8ae7b6b1..c0204e641c 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -13,6 +13,8 @@ */ #include "sysemu.h" +#include "qapi/qapi-types-misc.h" +#include "qapi/qapi-types-ui.h" /* replay clock kinds */ enum ReplayClockKind { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 77bb3da582..bfbef9e69c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -2,6 +2,7 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ +#include "qapi/qapi-types-run-state.h" #include "qemu/queue.h" #include "qemu/timer.h" #include "qemu/notify.h" diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 32b753d4f3..9ae1ab6da3 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -12,6 +12,7 @@ #ifndef QEMU_TPM_H #define QEMU_TPM_H +#include "qapi/qapi-types-tpm.h" #include "qom/object.h" int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); diff --git a/include/sysemu/watchdog.h b/include/sysemu/watchdog.h index 677ace3945..a08d16380d 100644 --- a/include/sysemu/watchdog.h +++ b/include/sysemu/watchdog.h @@ -23,7 +23,7 @@ #define QEMU_WATCHDOG_H #include "qemu/queue.h" -#include "qapi-types.h" +#include "qapi/qapi-types-run-state.h" struct WatchdogTimerModel { QLIST_ENTRY(WatchdogTimerModel) entry; diff --git a/include/ui/console.h b/include/ui/console.h index f29bacd625..e0d81f1144 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -5,6 +5,7 @@ #include "qom/object.h" #include "qemu/notify.h" #include "qemu/error-report.h" +#include "qapi/qapi-types-ui.h" #ifdef CONFIG_OPENGL # include <epoxy/gl.h> diff --git a/include/ui/input.h b/include/ui/input.h index ceb22b8eef..16395ab8f2 100644 --- a/include/ui/input.h +++ b/include/ui/input.h @@ -1,7 +1,7 @@ #ifndef INPUT_H #define INPUT_H -#include "qapi-types.h" +#include "qapi/qapi-types-ui.h" #define INPUT_EVENT_MASK_KEY (1<<INPUT_EVENT_KIND_KEY) #define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN) diff --git a/io/channel-socket.c b/io/channel-socket.c index 563e297357..8359b6683a 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-sockets.h" #include "io/channel-socket.h" #include "io/channel-watch.h" #include "trace.h" diff --git a/io/dns-resolver.c b/io/dns-resolver.c index c072d121c3..8c924071c4 100644 --- a/io/dns-resolver.c +++ b/io/dns-resolver.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "io/dns-resolver.h" #include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-sockets.h" #include "qemu/sockets.h" #include "qapi/error.h" #include "qemu/cutils.h" diff --git a/iothread.c b/iothread.c index 4b9bbde4cd..2ec5a3bffe 100644 --- a/iothread.c +++ b/iothread.c @@ -18,8 +18,8 @@ #include "block/aio.h" #include "block/block.h" #include "sysemu/iothread.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/error-report.h" #include "qemu/rcu.h" #include "qemu/main-loop.h" diff --git a/migration/colo-failover.c b/migration/colo-failover.c index 891785cb63..0ae0c41221 100644 --- a/migration/colo-failover.c +++ b/migration/colo-failover.c @@ -15,8 +15,8 @@ #include "migration/failover.h" #include "qemu/main-loop.h" #include "migration.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "trace.h" diff --git a/migration/colo.c b/migration/colo.c index 245a46d59d..4381067ed4 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" #include "qemu-file-channel.h" #include "migration.h" #include "qemu-file.h" @@ -24,7 +25,6 @@ #include "qemu/error-report.h" #include "migration/failover.h" #include "replication.h" -#include "qmp-commands.h" static bool vmstate_loading; diff --git a/migration/migration.c b/migration/migration.c index 0aa596f867..e345d0cc7e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -31,15 +31,15 @@ #include "migration/vmstate.h" #include "block/block.h" #include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-events-migration.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qnull.h" #include "qemu/rcu.h" #include "block.h" #include "postcopy-ram.h" #include "qemu/thread.h" -#include "qmp-commands.h" #include "trace.h" -#include "qapi-event.h" #include "exec/target_page.h" #include "io/channel-buffer.h" #include "migration/colo.h" diff --git a/migration/migration.h b/migration/migration.h index 82cf926b17..08c5d2ded1 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -15,6 +15,7 @@ #define QEMU_MIGRATION_H #include "qemu-common.h" +#include "qapi/qapi-types-migration.h" #include "qemu/thread.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" diff --git a/migration/ram.c b/migration/ram.c index 5e33e5cc79..3b6c077964 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -29,7 +29,6 @@ #include "qemu/osdep.h" #include "cpu.h" #include <zlib.h> -#include "qapi-event.h" #include "qemu/cutils.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" @@ -44,6 +43,7 @@ #include "migration/page_cache.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/qapi-events-migration.h" #include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" diff --git a/migration/ram.h b/migration/ram.h index f3a227b4fc..53f0021c51 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -30,7 +30,7 @@ #define QEMU_MIGRATION_RAM_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-migration.h" #include "exec/cpu-common.h" extern MigrationStats ram_counters; diff --git a/migration/savevm.c b/migration/savevm.c index 8e6d872452..358c5b51e2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -41,12 +41,13 @@ #include "savevm.h" #include "postcopy-ram.h" #include "qapi/error.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "sysemu/cpus.h" #include "exec/memory.h" #include "exec/target_page.h" -#include "qmp-commands.h" #include "trace.h" #include "qemu/iov.h" #include "block/snapshot.h" @@ -69,14 +69,14 @@ #include "exec/exec-all.h" #include "qemu/log.h" #include "qemu/option.h" -#include "qmp-commands.h" #include "hmp.h" #include "qemu/thread.h" #include "block/qapi.h" +#include "qapi/qapi-commands.h" +#include "qapi/qapi-events.h" #include "qapi/error.h" #include "qapi/qmp-event.h" -#include "qapi-event.h" -#include "qmp-introspect.h" +#include "qapi/qapi-introspect.h" #include "sysemu/qtest.h" #include "sysemu/cpus.h" #include "qemu/cutils.h" @@ -951,7 +951,7 @@ EventInfoList *qmp_query_events(Error **errp) * visit_type_SchemaInfoList() into a SchemaInfoList, then marshal it * to QObject with generated output marshallers, every time. Instead, * we do it in test-qobject-input-visitor.c, just to make sure - * qapi-introspect.py's output actually conforms to the schema. + * qapi-gen.py's output actually conforms to the schema. */ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, Error **errp) diff --git a/net/colo-compare.c b/net/colo-compare.c index 76e03fdb14..23b2d2c4cc 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -25,7 +25,6 @@ #include "net/queue.h" #include "chardev/char-fe.h" #include "qemu/sockets.h" -#include "qapi-visit.h" #include "net/colo.h" #include "sysemu/iothread.h" diff --git a/net/filter-buffer.c b/net/filter-buffer.c index 9ce96aaa35..f7265c50a8 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -13,8 +13,8 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "qemu/iov.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/qmp/qerror.h" -#include "qapi-visit.h" #include "qom/object.h" #define TYPE_FILTER_BUFFER "filter-buffer" diff --git a/net/filter-mirror.c b/net/filter-mirror.c index bd78e25d12..3a61cf21e8 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -14,7 +14,6 @@ #include "net/net.h" #include "qemu-common.h" #include "qapi/error.h" -#include "qapi-visit.h" #include "qom/object.h" #include "qemu/main-loop.h" #include "qemu/error-report.h" diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index 6201494ceb..62dad2d773 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -16,7 +16,6 @@ #include "net/net.h" #include "qemu-common.h" #include "qemu/error-report.h" -#include "qapi-visit.h" #include "qom/object.h" #include "qemu/main-loop.h" #include "qemu/iov.h" @@ -33,18 +33,18 @@ #include "monitor/monitor.h" #include "qemu/help_option.h" +#include "qapi/qapi-commands-net.h" +#include "qapi/qapi-visit-net.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" #include "qemu/sockets.h" #include "qemu/cutils.h" #include "qemu/config-file.h" -#include "qmp-commands.h" #include "hw/qdev.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/option.h" -#include "qapi-visit.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" #include "sysemu/sysemu.h" diff --git a/net/tap_int.h b/net/tap_int.h index ae6888f74a..9f931d52d6 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -27,7 +27,7 @@ #define NET_TAP_INT_H #include "qemu-common.h" -#include "qapi-types.h" +#include "qapi/qapi-types-net.h" int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp); diff --git a/net/vhost-user.c b/net/vhost-user.c index d024573e45..e0f16c895b 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -14,10 +14,10 @@ #include "net/vhost-user.h" #include "chardev/char-fe.h" #include "qapi/error.h" +#include "qapi/qapi-commands-net.h" #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/option.h" -#include "qmp-commands.h" #include "trace.h" typedef struct VhostUserState { @@ -29,12 +29,12 @@ #include "qemu/bitmap.h" #include "qom/cpu.h" #include "qemu/error-report.h" -#include "qapi-visit.h" #include "qapi/error.h" #include "qapi/opts-visitor.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-visit-misc.h" #include "hw/boards.h" #include "sysemu/hostmem.h" -#include "qmp-commands.h" #include "hw/mem/pc-dimm.h" #include "qemu/option.h" #include "qemu/config-file.h" diff --git a/qapi-schema.json b/qapi/misc.json index cd98a94388..a1702c9060 100644 --- a/qapi-schema.json +++ b/qapi/misc.json @@ -1,97 +1,5 @@ # -*- Mode: Python -*- -## -# = Introduction -# -# This document describes all commands currently supported by QMP. -# -# Most of the time their usage is exactly the same as in the user Monitor, this -# means that any other document which also describe commands (the manpage, -# QEMU's manual, etc) can and should be consulted. -# -# QMP has two types of commands: regular and query commands. Regular commands -# usually change the Virtual Machine's state someway, while query commands just -# return information. The sections below are divided accordingly. # -# It's important to observe that all communication examples are formatted in -# a reader-friendly way, so that they're easier to understand. However, in real -# protocol usage, they're emitted as a single line. -# -# Also, the following notation is used to denote data flow: -# -# Example: -# -# | -> data issued by the Client -# | <- Server data response -# -# Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for -# detailed information on the Server command and response formats. -# -# = Stability Considerations -# -# The current QMP command set (described in this file) may be useful for a -# number of use cases, however it's limited and several commands have bad -# defined semantics, specially with regard to command completion. -# -# These problems are going to be solved incrementally in the next QEMU releases -# and we're going to establish a deprecation policy for badly defined commands. -# -# If you're planning to adopt QMP, please observe the following: -# -# 1. The deprecation policy will take effect and be documented soon, please -# check the documentation of each used command as soon as a new release of -# QEMU is available -# -# 2. DO NOT rely on anything which is not explicit documented -# -# 3. Errors, in special, are not documented. Applications should NOT check -# for specific errors classes or data (it's strongly recommended to only -# check for the "error" key) -# -## - -{ 'pragma': { 'doc-required': true } } - -# Whitelists to permit QAPI rule violations; think twice before you -# add to them! -{ 'pragma': { - # Commands allowed to return a non-dictionary: - 'returns-whitelist': [ - 'human-monitor-command', - 'qom-get', - 'query-migrate-cache-size', - 'query-tpm-models', - 'query-tpm-types', - 'ringbuf-read' ], - 'name-case-whitelist': [ - 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status - 'CpuInfoMIPS', # PC, visible through query-cpu - 'CpuInfoTricore', # PC, visible through query-cpu - 'QapiErrorClass', # all members, visible through errors - 'UuidInfo', # UUID, visible through query-uuid - 'X86CPURegister32', # all members, visible indirectly through qom-get - 'q_obj_CpuInfo-base' # CPU, visible through query-cpu - ] } } - -# Documentation generated with qapi2texi.py is in source order, with -# included sub-schemas inserted at the first include directive -# (subsequent include directives have no effect). To get a sane and -# stable order, it's best to include each sub-schema just once, or -# include it first in qapi-schema.json. - -{ 'include': 'qapi/common.json' } -{ 'include': 'qapi/sockets.json' } -{ 'include': 'qapi/run-state.json' } -{ 'include': 'qapi/crypto.json' } -{ 'include': 'qapi/block.json' } -{ 'include': 'qapi/char.json' } -{ 'include': 'qapi/net.json' } -{ 'include': 'qapi/rocker.json' } -{ 'include': 'qapi/tpm.json' } -{ 'include': 'qapi/ui.json' } -{ 'include': 'qapi/migration.json' } -{ 'include': 'qapi/transaction.json' } -{ 'include': 'qapi/trace.json' } -{ 'include': 'qapi/introspect.json' } ## # = Miscellanea @@ -1821,7 +1729,7 @@ # # Emitted when background dump has completed # -# @result: DumpQueryResult type described in qapi-schema.json. +# @result: final dump status # # @error: human-readable error string that provides # hint on why dump failed. Only presents on failure. The @@ -3036,7 +2944,7 @@ # # Emitted when guest executes ACPI _OST method. # -# @info: ACPIOSTInfo type as described in qapi-schema.json +# @info: OSPM Status Indication # # Since: 2.1 # @@ -3291,12 +3199,3 @@ # Since: 2.9 ## { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' } - -## -# @watchdog-set-action: -# -# Set watchdog action -# -# Since: 2.11 -## -{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json new file mode 100644 index 0000000000..25bce78352 --- /dev/null +++ b/qapi/qapi-schema.json @@ -0,0 +1,95 @@ +# -*- Mode: Python -*- +## +# = Introduction +# +# This document describes all commands currently supported by QMP. +# +# Most of the time their usage is exactly the same as in the user Monitor, this +# means that any other document which also describe commands (the manpage, +# QEMU's manual, etc) can and should be consulted. +# +# QMP has two types of commands: regular and query commands. Regular commands +# usually change the Virtual Machine's state someway, while query commands just +# return information. The sections below are divided accordingly. +# +# It's important to observe that all communication examples are formatted in +# a reader-friendly way, so that they're easier to understand. However, in real +# protocol usage, they're emitted as a single line. +# +# Also, the following notation is used to denote data flow: +# +# Example: +# +# | -> data issued by the Client +# | <- Server data response +# +# Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for +# detailed information on the Server command and response formats. +# +# = Stability Considerations +# +# The current QMP command set (described in this file) may be useful for a +# number of use cases, however it's limited and several commands have bad +# defined semantics, specially with regard to command completion. +# +# These problems are going to be solved incrementally in the next QEMU releases +# and we're going to establish a deprecation policy for badly defined commands. +# +# If you're planning to adopt QMP, please observe the following: +# +# 1. The deprecation policy will take effect and be documented soon, please +# check the documentation of each used command as soon as a new release of +# QEMU is available +# +# 2. DO NOT rely on anything which is not explicit documented +# +# 3. Errors, in special, are not documented. Applications should NOT check +# for specific errors classes or data (it's strongly recommended to only +# check for the "error" key) +# +## + +{ 'pragma': { 'doc-required': true } } + +# Whitelists to permit QAPI rule violations; think twice before you +# add to them! +{ 'pragma': { + # Commands allowed to return a non-dictionary: + 'returns-whitelist': [ + 'human-monitor-command', + 'qom-get', + 'query-migrate-cache-size', + 'query-tpm-models', + 'query-tpm-types', + 'ringbuf-read' ], + 'name-case-whitelist': [ + 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status + 'CpuInfoMIPS', # PC, visible through query-cpu + 'CpuInfoTricore', # PC, visible through query-cpu + 'QapiErrorClass', # all members, visible through errors + 'UuidInfo', # UUID, visible through query-uuid + 'X86CPURegister32', # all members, visible indirectly through qom-get + 'q_obj_CpuInfo-base' # CPU, visible through query-cpu + ] } } + +# Documentation generated with qapi-gen.py is in source order, with +# included sub-schemas inserted at the first include directive +# (subsequent include directives have no effect). To get a sane and +# stable order, it's best to include each sub-schema just once, or +# include it first right here. + +{ 'include': 'common.json' } +{ 'include': 'sockets.json' } +{ 'include': 'run-state.json' } +{ 'include': 'crypto.json' } +{ 'include': 'block.json' } +{ 'include': 'char.json' } +{ 'include': 'net.json' } +{ 'include': 'rocker.json' } +{ 'include': 'tpm.json' } +{ 'include': 'ui.json' } +{ 'include': 'migration.json' } +{ 'include': 'transaction.json' } +{ 'include': 'trace.json' } +{ 'include': 'introspect.json' } +{ 'include': 'misc.json' } diff --git a/qapi/run-state.json b/qapi/run-state.json index 92d29fd571..1c9fff3aef 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -284,6 +284,15 @@ 'inject-nmi' ] } ## +# @watchdog-set-action: +# +# Set watchdog action +# +# Since: 2.11 +## +{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## # @GUEST_PANICKED: # # Emitted when guest OS panic is detected diff --git a/qdev-monitor.c b/qdev-monitor.c index 846238175f..b8f6bc3f7e 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -22,9 +22,9 @@ #include "hw/sysbus.h" #include "monitor/monitor.h" #include "monitor/qdev.h" -#include "qmp-commands.h" #include "sysemu/arch_init.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/config-file.h" diff --git a/qemu-img.c b/qemu-img.c index 56edc15218..40bf7aa7d1 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -27,7 +27,7 @@ #include "qemu-version.h" #include "qapi/error.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-block-core.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qdict.h" diff --git a/qga/Makefile.objs b/qga/Makefile.objs index 1c5986c0bb..ed08c5917c 100644 --- a/qga/Makefile.objs +++ b/qga/Makefile.objs @@ -3,6 +3,6 @@ qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o qga-obj-$(CONFIG_WIN32) += vss-win32.o qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o -qga-obj-y += qapi-generated/qga-qmp-marshal.o +qga-obj-y += qapi-generated/qga-qapi-commands.o qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/ diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 967061444a..ac17d0d6cf 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -17,7 +17,7 @@ #include <sys/wait.h> #include <dirent.h> #include "qga/guest-agent-core.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/queue.h" diff --git a/qga/commands-win32.c b/qga/commands-win32.c index bedae32957..2d48394748 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -34,7 +34,7 @@ #include "qga/guest-agent-core.h" #include "qga/vss-win32.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/queue.h" diff --git a/qga/commands.c b/qga/commands.c index 6d710dbb20..a64b34ccab 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -12,7 +12,7 @@ #include "qemu/osdep.h" #include "qga/guest-agent-core.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qemu/base64.h" diff --git a/qga/main.c b/qga/main.c index cb434d8c46..f9c83050c5 100644 --- a/qga/main.c +++ b/qga/main.c @@ -25,7 +25,7 @@ #include "qapi/qmp/qstring.h" #include "qga/guest-agent-core.h" #include "qemu/module.h" -#include "qga-qmp-commands.h" +#include "qga-qapi-commands.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "qga/channel.h" @@ -21,7 +21,6 @@ #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/uuid.h" -#include "qmp-commands.h" #include "chardev/char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" @@ -32,6 +31,9 @@ #include "sysemu/block-backend.h" #include "qom/qom-qobject.h" #include "qapi/error.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" @@ -145,13 +147,13 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp) #ifndef CONFIG_SPICE /* - * qmp-commands.hx ensures that QMP command query-spice exists only - * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands - * result. However, the QAPI schema is blissfully unaware of that, - * and the QAPI code generator happily generates a dead - * qmp_marshal_query_spice() that calls qmp_query_spice(). Provide it - * one, or else linking fails. FIXME Educate the QAPI schema on - * CONFIG_SPICE. + * qmp_unregister_commands_hack() ensures that QMP command query-spice + * exists only #ifdef CONFIG_SPICE. Necessary for an accurate + * query-commands result. However, the QAPI schema is blissfully + * unaware of that, and the QAPI code generator happily generates a + * dead qmp_marshal_query_spice() that calls qmp_query_spice(). + * Provide it one, or else linking fails. FIXME Educate the QAPI + * schema on CONFIG_SPICE. */ SpiceInfo *qmp_query_spice(Error **errp) { diff --git a/qom/object.c b/qom/object.c index 5dcee4683c..f70a75c308 100644 --- a/qom/object.c +++ b/qom/object.c @@ -16,9 +16,9 @@ #include "qom/object_interfaces.h" #include "qemu/cutils.h" #include "qapi/visitor.h" -#include "qapi-visit.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" +#include "qapi/qapi-builtin-visit.h" #include "qapi/qmp/qerror.h" #include "trace.h" diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 80d09139be..2f76e1f36d 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -1,10 +1,10 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qerror.h" #include "qom/object_interfaces.h" #include "qemu/module.h" #include "qemu/option.h" -#include "qapi-visit.h" #include "qapi/opts-visitor.h" #include "qemu/config-file.h" diff --git a/replay/replay-input.c b/replay/replay-input.c index 3ab1536bf7..6ee8b5f8db 100644 --- a/replay/replay-input.c +++ b/replay/replay-input.c @@ -16,6 +16,7 @@ #include "qemu/notify.h" #include "ui/input.h" #include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-ui.h" void replay_save_input_event(InputEvent *evt) { diff --git a/replication.h b/replication.h index ece6ca6133..8faefe005f 100644 --- a/replication.h +++ b/replication.h @@ -15,6 +15,7 @@ #ifndef REPLICATION_H #define REPLICATION_H +#include "qapi/qapi-types-block-core.h" #include "qemu/queue.h" typedef struct ReplicationOps ReplicationOps; diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py new file mode 100755 index 0000000000..3d98ca2e0c --- /dev/null +++ b/scripts/qapi-gen.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# QAPI generator +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +from __future__ import print_function +import argparse +import re +import sys +from qapi.common import QAPIError, QAPISchema +from qapi.types import gen_types +from qapi.visit import gen_visit +from qapi.commands import gen_commands +from qapi.events import gen_events +from qapi.introspect import gen_introspect +from qapi.doc import gen_doc + + +def main(argv): + parser = argparse.ArgumentParser( + description='Generate code from a QAPI schema') + parser.add_argument('-b', '--builtins', action='store_true', + help="generate code for built-in types") + parser.add_argument('-o', '--output-dir', action='store', default='', + help="write output to directory OUTPUT_DIR") + parser.add_argument('-p', '--prefix', action='store', default='', + help="prefix for symbols") + parser.add_argument('-u', '--unmask-non-abi-names', action='store_true', + dest='unmask', + help="expose non-ABI names in introspection") + parser.add_argument('schema', action='store') + args = parser.parse_args() + + match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', args.prefix) + if match.end() != len(args.prefix): + print("%s: 'funny character '%s' in argument of --prefix" + % (sys.argv[0], args.prefix[match.end()]), + file=sys.stderr) + sys.exit(1) + + try: + schema = QAPISchema(args.schema) + except QAPIError as err: + print(err, file=sys.stderr) + exit(1) + + gen_types(schema, args.output_dir, args.prefix, args.builtins) + gen_visit(schema, args.output_dir, args.prefix, args.builtins) + gen_commands(schema, args.output_dir, args.prefix) + gen_events(schema, args.output_dir, args.prefix) + gen_introspect(schema, args.output_dir, args.prefix, args.unmask) + gen_doc(schema, args.output_dir, args.prefix) + + +if __name__ == '__main__': + main(sys.argv) diff --git a/scripts/qapi/__init__.py b/scripts/qapi/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/scripts/qapi/__init__.py diff --git a/scripts/qapi-commands.py b/scripts/qapi/commands.py index f89d748ba4..21a7e0dbe6 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi/commands.py @@ -1,18 +1,19 @@ -# -# QAPI command marshaller generator -# -# Copyright IBM, Corp. 2011 -# Copyright (C) 2014-2016 Red Hat, Inc. -# -# Authors: -# Anthony Liguori <aliguori@us.ibm.com> -# Michael Roth <mdroth@linux.vnet.ibm.com> -# Markus Armbruster <armbru@redhat.com> -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. - -from qapi import * +""" +QAPI command marshaller generator + +Copyright IBM, Corp. 2011 +Copyright (C) 2014-2018 Red Hat, Inc. + +Authors: + Anthony Liguori <aliguori@us.ibm.com> + Michael Roth <mdroth@linux.vnet.ibm.com> + Markus Armbruster <armbru@redhat.com> + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" + +from qapi.common import * def gen_command_decl(name, arg_type, boxed, ret_type): @@ -206,7 +207,7 @@ def gen_register_command(name, success_response): return ret -def gen_registry(registry): +def gen_registry(registry, prefix): ret = mcgen(''' void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) @@ -222,74 +223,21 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) return ret -class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): - def __init__(self): - self.decl = None - self.defn = None - self._regy = None - self._visited_ret_types = None +class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): - def visit_begin(self, schema): - self.decl = '' - self.defn = '' + def __init__(self, prefix): + QAPISchemaModularCVisitor.__init__( + self, prefix, 'qapi-commands', + ' * Schema-defined QAPI/QMP commands', __doc__) self._regy = '' - self._visited_ret_types = set() - - def visit_end(self): - self.defn += gen_registry(self._regy) - self._regy = None - self._visited_ret_types = None - - def visit_command(self, name, info, arg_type, ret_type, - gen, success_response, boxed): - if not gen: - return - self.decl += gen_command_decl(name, arg_type, boxed, ret_type) - if ret_type and ret_type not in self._visited_ret_types: - self._visited_ret_types.add(ret_type) - self.defn += gen_marshal_output(ret_type) - self.decl += gen_marshal_decl(name) - self.defn += gen_marshal(name, arg_type, boxed, ret_type) - self._regy += gen_register_command(name, success_response) - - -(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line() - -c_comment = ''' -/* - * schema-defined QMP->QAPI command dispatch - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * - * 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. - * - */ -''' -h_comment = ''' -/* - * schema-defined QAPI function prototypes - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * - * 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. - * - */ -''' - -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix, - 'qmp-marshal.c', 'qmp-commands.h', - c_comment, h_comment) - -fdef.write(mcgen(''' - + self._visited_ret_types = {} + + def _begin_module(self, name): + self._visited_ret_types[self._genc] = set() + commands = self._module_basename('qapi-commands', 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 "qemu/module.h" @@ -299,25 +247,40 @@ fdef.write(mcgen(''' #include "qapi/qobject-input-visitor.h" #include "qapi/dealloc-visitor.h" #include "qapi/error.h" -#include "%(prefix)sqapi-types.h" -#include "%(prefix)sqapi-visit.h" -#include "%(prefix)sqmp-commands.h" +#include "%(visit)s.h" +#include "%(commands)s.h" ''', - prefix=prefix)) - -fdecl.write(mcgen(''' -#include "%(prefix)sqapi-types.h" + commands=commands, visit=visit)) + self._genh.add(mcgen(''' +#include "%(types)s.h" #include "qapi/qmp/dispatch.h" +''', + types=types)) + + def visit_end(self): + (genc, genh) = self._module[self._main_module] + genh.add(mcgen(''' void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); ''', - prefix=prefix, c_prefix=c_name(prefix, protect=False))) + c_prefix=c_name(self._prefix, protect=False))) + genc.add(gen_registry(self._regy, self._prefix)) + + def visit_command(self, name, info, arg_type, ret_type, + gen, success_response, boxed): + if not gen: + return + self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type)) + if ret_type and ret_type not in self._visited_ret_types[self._genc]: + self._visited_ret_types[self._genc].add(ret_type) + self._genc.add(gen_marshal_output(ret_type)) + self._genh.add(gen_marshal_decl(name)) + self._genc.add(gen_marshal(name, arg_type, boxed, ret_type)) + self._regy += gen_register_command(name, success_response) -schema = QAPISchema(input_file) -gen = QAPISchemaGenCommandVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) -close_output(fdef, fdecl) +def gen_commands(schema, output_dir, prefix): + vis = QAPISchemaGenCommandVisitor(prefix) + schema.visit(vis) + vis.write(output_dir) diff --git a/scripts/qapi.py b/scripts/qapi/common.py index 58f995b07f..97e9060b67 100644 --- a/scripts/qapi.py +++ b/scripts/qapi/common.py @@ -2,7 +2,7 @@ # QAPI helper library # # Copyright IBM, Corp. 2011 -# Copyright (c) 2013-2016 Red Hat Inc. +# Copyright (c) 2013-2018 Red Hat Inc. # # Authors: # Anthony Liguori <aliguori@us.ibm.com> @@ -13,19 +13,13 @@ from __future__ import print_function import errno -import getopt import os import re import string -import sys try: from collections import OrderedDict except: from ordereddict import OrderedDict -try: - from StringIO import StringIO -except ImportError: - from io import StringIO builtin_types = { 'null': 'QTYPE_QNULL', @@ -264,9 +258,8 @@ class QAPIDoc(object): class QAPISchemaParser(object): def __init__(self, fp, previously_included=[], incl_info=None): - abs_fname = os.path.abspath(fp.name) self.fname = fp.name - previously_included.append(abs_fname) + previously_included.append(os.path.abspath(fp.name)) self.incl_info = incl_info self.src = fp.read() if self.src == '' or self.src[-1] != '\n': @@ -297,8 +290,15 @@ class QAPISchemaParser(object): if not isinstance(include, str): raise QAPISemError(info, "Value of 'include' must be a string") - self._include(include, info, os.path.dirname(abs_fname), - previously_included) + incl_fname = os.path.join(os.path.dirname(self.fname), + include) + self.exprs.append({'expr': {'include': incl_fname}, + 'info': info}) + exprs_include = self._include(include, info, incl_fname, + previously_included) + if exprs_include: + self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) elif "pragma" in expr: self.reject_expr_doc(cur_doc) if len(expr) != 1: @@ -329,8 +329,8 @@ class QAPISchemaParser(object): "Documentation for '%s' is not followed by the definition" % doc.symbol) - def _include(self, include, info, base_dir, previously_included): - incl_abs_fname = os.path.join(base_dir, include) + def _include(self, include, info, incl_fname, previously_included): + incl_abs_fname = os.path.abspath(incl_fname) # catch inclusion cycle inf = info while inf: @@ -340,14 +340,13 @@ class QAPISchemaParser(object): # skip multiple include of the same file if incl_abs_fname in previously_included: - return + return None + try: - fobj = open(incl_abs_fname, 'r') + fobj = open(incl_fname, 'r') except IOError as e: - raise QAPISemError(info, '%s: %s' % (e.strerror, include)) - exprs_include = QAPISchemaParser(fobj, previously_included, info) - self.exprs.extend(exprs_include.exprs) - self.docs.extend(exprs_include.docs) + raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname)) + return QAPISchemaParser(fobj, previously_included, info) def _pragma(self, name, value, info): global doc_required, returns_whitelist, name_case_whitelist @@ -896,6 +895,9 @@ def check_exprs(exprs): info = expr_elem['info'] doc = expr_elem.get('doc') + if 'include' in expr: + continue + if not doc and doc_required: raise QAPISemError(info, "Expression missing documentation comment") @@ -935,6 +937,9 @@ def check_exprs(exprs): # Try again for hidden UnionKind enum for expr_elem in exprs: expr = expr_elem['expr'] + + if 'include' in expr: + continue if 'union' in expr and not discriminator_find_enum_define(expr): name = '%sKind' % expr['union'] elif 'alternate' in expr: @@ -950,6 +955,8 @@ def check_exprs(exprs): info = expr_elem['info'] doc = expr_elem.get('doc') + if 'include' in expr: + continue if 'enum' in expr: check_enum(expr, info) elif 'union' in expr: @@ -977,8 +984,9 @@ def check_exprs(exprs): class QAPISchemaEntity(object): def __init__(self, name, info, doc): - assert isinstance(name, str) + assert name is None or isinstance(name, str) self.name = name + self.module = None # For explicitly defined entities, info points to the (explicit) # definition. For builtins (and their arrays), info is None. # For implicitly defined entities, info points to a place that @@ -1007,10 +1015,16 @@ class QAPISchemaVisitor(object): def visit_end(self): pass + def visit_module(self, fname): + pass + def visit_needed(self, entity): # Default to visiting everything return True + def visit_include(self, fname, info): + pass + def visit_builtin_type(self, name, info, json_type): pass @@ -1037,6 +1051,16 @@ class QAPISchemaVisitor(object): pass +class QAPISchemaInclude(QAPISchemaEntity): + + def __init__(self, fname, info): + QAPISchemaEntity.__init__(self, None, info, None) + self.fname = fname + + def visit(self, visitor): + visitor.visit_include(self.fname, self.info) + + class QAPISchemaType(QAPISchemaEntity): # Return the C type for common use. # For the types we commonly box, this is a pointer type. @@ -1464,25 +1488,28 @@ class QAPISchemaEvent(QAPISchemaEntity): class QAPISchema(object): def __init__(self, fname): - try: - parser = QAPISchemaParser(open(fname, 'r')) - self.exprs = check_exprs(parser.exprs) - self.docs = parser.docs - self._entity_dict = {} - self._predefining = True - self._def_predefineds() - self._predefining = False - self._def_exprs() - self.check() - except QAPIError as err: - print(err, file=sys.stderr) - exit(1) + self._fname = fname + parser = QAPISchemaParser(open(fname, 'r')) + exprs = check_exprs(parser.exprs) + self.docs = parser.docs + self._entity_list = [] + self._entity_dict = {} + self._predefining = True + self._def_predefineds() + self._predefining = False + self._def_exprs(exprs) + self.check() def _def_entity(self, ent): # Only the predefined types are allowed to not have info assert ent.info or self._predefining - assert ent.name not in self._entity_dict - self._entity_dict[ent.name] = ent + assert ent.name is None or ent.name not in self._entity_dict + self._entity_list.append(ent) + if ent.name is not None: + self._entity_dict[ent.name] = ent + if ent.info: + ent.module = os.path.relpath(ent.info['file'], + os.path.dirname(self._fname)) def lookup_entity(self, name, typ=None): ent = self._entity_dict.get(name) @@ -1493,13 +1520,21 @@ class QAPISchema(object): def lookup_type(self, name): return self.lookup_entity(name, QAPISchemaType) + def _def_include(self, expr, info, doc): + include = expr['include'] + assert doc is None + main_info = info + while main_info['parent']: + main_info = main_info['parent'] + fname = os.path.relpath(include, os.path.dirname(main_info['file'])) + self._def_entity(QAPISchemaInclude(fname, info)) + def _def_builtin_type(self, name, json_type, c_type): self._def_entity(QAPISchemaBuiltinType(name, json_type, c_type)) - # TODO As long as we have QAPI_TYPES_BUILTIN to share multiple - # qapi-types.h from a single .c, all arrays of builtins must be - # declared in the first file whether or not they are used. Nicer - # would be to use lazy instantiation, while figuring out how to - # avoid compilation issues with multiple qapi-types.h. + # Instantiating only the arrays that are actually used would + # be nice, but we can't as long as their generated code + # (qapi-builtin-types.[ch]) may be shared by some other + # schema. self._make_array_type(name, None) def _def_predefineds(self): @@ -1657,8 +1692,8 @@ class QAPISchema(object): name, info, doc, 'arg', self._make_members(data, info)) self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed)) - def _def_exprs(self): - for expr_elem in self.exprs: + def _def_exprs(self, exprs): + for expr_elem in exprs: expr = expr_elem['expr'] info = expr_elem['info'] doc = expr_elem.get('doc') @@ -1674,17 +1709,23 @@ class QAPISchema(object): self._def_command(expr, info, doc) elif 'event' in expr: self._def_event(expr, info, doc) + elif 'include' in expr: + self._def_include(expr, info, doc) else: assert False def check(self): - for (name, ent) in sorted(self._entity_dict.items()): + for ent in self._entity_list: ent.check(self) def visit(self, visitor): visitor.visit_begin(self) - for (name, entity) in sorted(self._entity_dict.items()): + module = None + for entity in self._entity_list: if visitor.visit_needed(entity): + if entity.module != module: + module = entity.module + visitor.visit_module(module) entity.visit(visitor) visitor.visit_end() @@ -1826,12 +1867,11 @@ def mcgen(code, **kwds): def guardname(filename): - return c_name(filename, protect=False).upper() + return re.sub(r'[^A-Za-z0-9_]', '_', filename).upper() def guardstart(name): return mcgen(''' - #ifndef %(name)s #define %(name)s @@ -1843,7 +1883,6 @@ def guardend(name): return mcgen(''' #endif /* %(name)s */ - ''', name=guardname(name)) @@ -1930,104 +1969,161 @@ def build_params(arg_type, boxed, extra): # -# Common command line parsing +# Accumulate and write output # +class QAPIGen(object): + + def __init__(self): + self._preamble = '' + self._body = '' + + def preamble_add(self, text): + self._preamble += text + + def add(self, text): + self._body += text + + def _top(self, fname): + return '' + + def _bottom(self, fname): + return '' + + def write(self, output_dir, fname): + pathname = os.path.join(output_dir, fname) + dir = os.path.dirname(pathname) + if dir: + try: + os.makedirs(dir) + except os.error as e: + if e.errno != errno.EEXIST: + raise + fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) + f = os.fdopen(fd, 'r+') + text = (self._top(fname) + self._preamble + self._body + + self._bottom(fname)) + oldtext = f.read(len(text) + 1) + if text != oldtext: + f.seek(0) + f.truncate(0) + f.write(text) + f.close() + + +class QAPIGenC(QAPIGen): + + def __init__(self, blurb, pydoc): + QAPIGen.__init__(self) + self._blurb = blurb + self._copyright = '\n * '.join(re.findall(r'^Copyright .*', pydoc, + re.MULTILINE)) + + def _top(self, fname): + return mcgen(''' +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ -def parse_command_line(extra_options='', extra_long_options=[]): - - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], - 'chp:o:' + extra_options, - ['source', 'header', 'prefix=', - 'output-dir='] + extra_long_options) - except getopt.GetoptError as err: - print("%s: %s" % (sys.argv[0], str(err)), file=sys.stderr) - sys.exit(1) - - output_dir = '' - prefix = '' - do_c = False - do_h = False - extra_opts = [] - - for oa in opts: - o, a = oa - if o in ('-p', '--prefix'): - match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) - if match.end() != len(a): - print("%s: 'funny character '%s' in argument of --prefix" \ - % (sys.argv[0], a[match.end()]), file=sys.stderr) - sys.exit(1) - prefix = a - elif o in ('-o', '--output-dir'): - output_dir = a + '/' - elif o in ('-c', '--source'): - do_c = True - elif o in ('-h', '--header'): - do_h = True - else: - extra_opts.append(oa) +/* +%(blurb)s + * + * %(copyright)s + * + * 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. + */ - if not do_c and not do_h: - do_c = True - do_h = True +''', + blurb=self._blurb, copyright=self._copyright) - if len(args) != 1: - print("%s: need exactly one argument" % sys.argv[0], file=sys.stderr) - sys.exit(1) - fname = args[0] + def _bottom(self, fname): + return mcgen(''' +/* Dummy declaration to prevent empty .o file */ +char dummy_%(name)s; +''', + name=c_name(fname)) - return (fname, output_dir, do_c, do_h, prefix, extra_opts) -# -# Generate output files with boilerplate -# +class QAPIGenH(QAPIGenC): + def _top(self, fname): + return QAPIGenC._top(self, fname) + guardstart(fname) -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, - c_comment, h_comment): - guard = guardname(prefix + h_file) - c_file = output_dir + prefix + c_file - h_file = output_dir + prefix + h_file + def _bottom(self, fname): + return guardend(fname) - if output_dir: - try: - os.makedirs(output_dir) - except os.error as e: - if e.errno != errno.EEXIST: - raise - - def maybe_open(really, name, opt): - if really: - return open(name, opt) - else: - return StringIO() - fdef = maybe_open(do_c, c_file, 'w') - fdecl = maybe_open(do_h, h_file, 'w') +class QAPIGenDoc(QAPIGen): - fdef.write(mcgen(''' -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ -%(comment)s -''', - comment=c_comment)) + def _top(self, fname): + return (QAPIGen._top(self, fname) + + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') - fdecl.write(mcgen(''' -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ -%(comment)s -#ifndef %(guard)s -#define %(guard)s -''', - comment=h_comment, guard=guard)) +class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): + + def __init__(self, prefix, what, blurb, pydoc): + self._prefix = prefix + self._what = what + self._genc = QAPIGenC(blurb, pydoc) + self._genh = QAPIGenH(blurb, pydoc) - return (fdef, fdecl) + def write(self, output_dir): + self._genc.write(output_dir, self._prefix + self._what + '.c') + self._genh.write(output_dir, self._prefix + self._what + '.h') -def close_output(fdef, fdecl): - fdecl.write(''' -#endif -''') - fdecl.close() - fdef.close() +class QAPISchemaModularCVisitor(QAPISchemaVisitor): + + def __init__(self, prefix, what, blurb, pydoc): + self._prefix = prefix + self._what = what + self._blurb = blurb + self._pydoc = pydoc + self._module = {} + self._main_module = None + + def _module_basename(self, what, name): + if name is None: + return re.sub(r'-', '-builtin-', what) + basename = os.path.join(os.path.dirname(name), + self._prefix + what) + if name == self._main_module: + return basename + return basename + '-' + os.path.splitext(os.path.basename(name))[0] + + def _add_module(self, name, blurb): + if self._main_module is None and name is not None: + self._main_module = name + genc = QAPIGenC(blurb, self._pydoc) + genh = QAPIGenH(blurb, self._pydoc) + self._module[name] = (genc, genh) + self._set_module(name) + + def _set_module(self, name): + self._genc, self._genh = self._module[name] + + def write(self, output_dir, opt_builtins=False): + for name in self._module: + if name is None and not opt_builtins: + continue + basename = self._module_basename(self._what, name) + (genc, genh) = self._module[name] + genc.write(output_dir, basename + '.c') + genh.write(output_dir, basename + '.h') + + def _begin_module(self, name): + pass + + def visit_module(self, name): + if name in self._module: + self._set_module(name) + return + self._add_module(name, self._blurb) + self._begin_module(name) + + def visit_include(self, name, info): + basename = self._module_basename(self._what, name) + self._genh.preamble_add(mcgen(''' +#include "%(basename)s.h" +''', + basename=basename)) diff --git a/scripts/qapi2texi.py b/scripts/qapi/doc.py index bf1c57b2e2..0ea68bf813 100755..100644 --- a/scripts/qapi2texi.py +++ b/scripts/qapi/doc.py @@ -4,11 +4,10 @@ # This work is licensed under the terms of the GNU LGPL, version 2+. # See the COPYING file in the top-level directory. """This script produces the documentation of a qapi schema in texinfo format""" + from __future__ import print_function import re -import sys - -import qapi +import qapi.common MSG_FMT = """ @deftypefn {type} {{}} {name} @@ -197,34 +196,36 @@ def texi_entity(doc, what, base=None, variants=None, + texi_sections(doc)) -class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): - def __init__(self): - self.out = None +class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): + def __init__(self, prefix): + self._prefix = prefix + self._gen = qapi.common.QAPIGenDoc() self.cur_doc = None - def visit_begin(self, schema): - self.out = '' + def write(self, output_dir): + self._gen.write(output_dir, self._prefix + 'qapi-doc.texi') def visit_enum_type(self, name, info, values, prefix): doc = self.cur_doc - self.out += TYPE_FMT(type='Enum', - name=doc.symbol, - body=texi_entity(doc, 'Values', - member_func=texi_enum_value)) + self._gen.add(TYPE_FMT(type='Enum', + name=doc.symbol, + body=texi_entity(doc, 'Values', + member_func=texi_enum_value))) def visit_object_type(self, name, info, base, members, variants): doc = self.cur_doc if base and base.is_implicit(): base = None - self.out += TYPE_FMT(type='Object', - name=doc.symbol, - body=texi_entity(doc, 'Members', base, variants)) + self._gen.add(TYPE_FMT(type='Object', + name=doc.symbol, + body=texi_entity(doc, 'Members', + base, variants))) def visit_alternate_type(self, name, info, variants): doc = self.cur_doc - self.out += TYPE_FMT(type='Alternate', - name=doc.symbol, - body=texi_entity(doc, 'Members')) + self._gen.add(TYPE_FMT(type='Alternate', + name=doc.symbol, + body=texi_entity(doc, 'Members'))) def visit_command(self, name, info, arg_type, ret_type, gen, success_response, boxed): @@ -236,55 +237,38 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): body += texi_sections(doc) else: body = texi_entity(doc, 'Arguments') - self.out += MSG_FMT(type='Command', - name=doc.symbol, - body=body) + self._gen.add(MSG_FMT(type='Command', + name=doc.symbol, + body=body)) def visit_event(self, name, info, arg_type, boxed): doc = self.cur_doc - self.out += MSG_FMT(type='Event', - name=doc.symbol, - body=texi_entity(doc, 'Arguments')) + self._gen.add(MSG_FMT(type='Event', + name=doc.symbol, + body=texi_entity(doc, 'Arguments'))) def symbol(self, doc, entity): - if self.out: - self.out += '\n' + if self._gen._body: + self._gen.add('\n') self.cur_doc = doc entity.visit(self) self.cur_doc = None def freeform(self, doc): assert not doc.args - if self.out: - self.out += '\n' - self.out += texi_body(doc) + texi_sections(doc) + if self._gen._body: + self._gen.add('\n') + self._gen.add(texi_body(doc) + texi_sections(doc)) -def texi_schema(schema): - """Convert QAPI schema documentation to Texinfo""" - gen = QAPISchemaGenDocVisitor() - gen.visit_begin(schema) +def gen_doc(schema, output_dir, prefix): + if not qapi.common.doc_required: + return + vis = QAPISchemaGenDocVisitor(prefix) + vis.visit_begin(schema) for doc in schema.docs: if doc.symbol: - gen.symbol(doc, schema.lookup_entity(doc.symbol)) + vis.symbol(doc, schema.lookup_entity(doc.symbol)) else: - gen.freeform(doc) - return gen.out - - -def main(argv): - """Takes schema argument, prints result to stdout""" - if len(argv) != 2: - print("%s: need exactly 1 argument: SCHEMA" % argv[0], file=sys.stderr) - sys.exit(1) - - schema = qapi.QAPISchema(argv[1]) - if not qapi.doc_required: - print("%s: need pragma 'doc-required' " - "to generate documentation" % argv[0], file=sys.stderr) - sys.exit(1) - print(texi_schema(schema)) - - -if __name__ == '__main__': - main(sys.argv) + vis.freeform(doc) + vis.write(output_dir) diff --git a/scripts/qapi-event.py b/scripts/qapi/events.py index c710968dc2..3dc523cf39 100644 --- a/scripts/qapi-event.py +++ b/scripts/qapi/events.py @@ -1,17 +1,18 @@ -# -# QAPI event generator -# -# Copyright (c) 2014 Wenchao Xia -# Copyright (c) 2015-2016 Red Hat Inc. -# -# Authors: -# Wenchao Xia <wenchaoqemu@gmail.com> -# Markus Armbruster <armbru@redhat.com> -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. - -from qapi import * +""" +QAPI event generator + +Copyright (c) 2014 Wenchao Xia +Copyright (c) 2015-2018 Red Hat Inc. + +Authors: + Wenchao Xia <wenchaoqemu@gmail.com> + Markus Armbruster <armbru@redhat.com> + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" + +from qapi.common import * def build_event_send_proto(name, arg_type, boxed): @@ -57,7 +58,7 @@ def gen_param_var(typ): return ret -def gen_event_send(name, arg_type, boxed): +def gen_event_send(name, arg_type, boxed, event_enum_name): # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in @@ -147,89 +148,48 @@ out: return ret -class QAPISchemaGenEventVisitor(QAPISchemaVisitor): - def __init__(self): - self.decl = None - self.defn = None - self._event_names = None +class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): - def visit_begin(self, schema): - self.decl = '' - self.defn = '' + def __init__(self, prefix): + QAPISchemaModularCVisitor.__init__( + self, prefix, 'qapi-events', + ' * Schema-defined QAPI/QMP events', __doc__) + self._enum_name = c_name(prefix + 'QAPIEvent', protect=False) self._event_names = [] - def visit_end(self): - self.decl += gen_enum(event_enum_name, self._event_names) - self.defn += gen_enum_lookup(event_enum_name, self._event_names) - self._event_names = None - - def visit_event(self, name, info, arg_type, boxed): - self.decl += gen_event_send_decl(name, arg_type, boxed) - self.defn += gen_event_send(name, arg_type, boxed) - self._event_names.append(name) - - -(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line() - -c_comment = ''' -/* - * schema-defined QAPI event functions - * - * Copyright (c) 2014 Wenchao Xia - * - * Authors: - * Wenchao Xia <wenchaoqemu@gmail.com> - * - * 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. - * - */ -''' -h_comment = ''' -/* - * schema-defined QAPI event functions - * - * Copyright (c) 2014 Wenchao Xia - * - * Authors: - * Wenchao Xia <wenchaoqemu@gmail.com> - * - * 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. - * - */ -''' - -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix, - 'qapi-event.c', 'qapi-event.h', - c_comment, h_comment) - -fdef.write(mcgen(''' + def _begin_module(self, 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-event.h" -#include "%(prefix)sqapi-visit.h" +#include "%(prefix)sqapi-events.h" +#include "%(visit)s.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp-event.h" ''', - prefix=prefix)) - -fdecl.write(mcgen(''' + visit=visit, prefix=self._prefix)) + self._genh.add(mcgen(''' #include "qapi/util.h" -#include "%(prefix)sqapi-types.h" +#include "%(types)s.h" ''', - prefix=prefix)) + types=types)) -event_enum_name = c_name(prefix + 'QAPIEvent', protect=False) + def visit_end(self): + self._genh.add(gen_enum(self._enum_name, self._event_names)) + self._genc.add(gen_enum_lookup(self._enum_name, self._event_names)) + + def visit_event(self, name, info, arg_type, boxed): + self._genh.add(gen_event_send_decl(name, arg_type, boxed)) + self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name)) + self._event_names.append(name) -schema = QAPISchema(input_file) -gen = QAPISchemaGenEventVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) -close_output(fdef, fdecl) +def gen_events(schema, output_dir, prefix): + vis = QAPISchemaGenEventVisitor(prefix) + schema.visit(vis) + vis.write(output_dir) diff --git a/scripts/qapi-introspect.py b/scripts/qapi/introspect.py index 032bcea491..f66c397fb0 100644 --- a/scripts/qapi-introspect.py +++ b/scripts/qapi/introspect.py @@ -1,15 +1,16 @@ -# -# QAPI introspection generator -# -# Copyright (C) 2015-2016 Red Hat, Inc. -# -# Authors: -# Markus Armbruster <armbru@redhat.com> -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. +""" +QAPI introspection generator -from qapi import * +Copyright (C) 2015-2018 Red Hat, Inc. + +Authors: + Markus Armbruster <armbru@redhat.com> + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" + +from qapi.common import * # Caveman's json.dumps() replacement (we're stuck at Python 2.4) @@ -39,21 +40,26 @@ def to_c_string(string): return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' -class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): - def __init__(self, unmask): +class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): + + def __init__(self, prefix, unmask): + QAPISchemaMonolithicCVisitor.__init__( + self, prefix, 'qapi-introspect', + ' * QAPI/QMP schema introspection', __doc__) self._unmask = unmask - self.defn = None - self.decl = None self._schema = None - self._jsons = None - self._used_types = None - self._name_map = None - - def visit_begin(self, schema): - self._schema = schema self._jsons = [] self._used_types = [] self._name_map = {} + self._genc.add(mcgen(''' +#include "qemu/osdep.h" +#include "%(prefix)sqapi-introspect.h" + +''', + prefix=prefix)) + + def visit_begin(self, schema): + self._schema = schema def visit_end(self): # visit the types that are actually used @@ -64,22 +70,22 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor): # generate C # TODO can generate awfully long lines jsons.extend(self._jsons) - name = c_name(prefix, protect=False) + 'qmp_schema_json' - self.decl = mcgen(''' + name = c_name(self._prefix, protect=False) + 'qmp_schema_json' + self._genh.add(mcgen(''' extern const char %(c_name)s[]; ''', - c_name=c_name(name)) + c_name=c_name(name))) lines = to_json(jsons).split('\n') c_string = '\n '.join([to_c_string(line) for line in lines]) - self.defn = mcgen(''' + self._genc.add(mcgen(''' const char %(c_name)s[] = %(c_string)s; ''', - c_name=c_name(name), - c_string=c_string) + c_name=c_name(name), + c_string=c_string)) self._schema = None - self._jsons = None - self._used_types = None - self._name_map = None + self._jsons = [] + self._used_types = [] + self._name_map = {} def visit_needed(self, entity): # Ignore types on first pass; visit_end() will pick up used types @@ -165,55 +171,8 @@ const char %(c_name)s[] = %(c_string)s; arg_type = arg_type or self._schema.the_empty_object_type self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)}) -# Debugging aid: unmask QAPI schema's type names -# We normally mask them, because they're not QMP wire ABI -opt_unmask = False - -(input_file, output_dir, do_c, do_h, prefix, opts) = \ - parse_command_line('u', ['unmask-non-abi-names']) - -for o, a in opts: - if o in ('-u', '--unmask-non-abi-names'): - opt_unmask = True - -c_comment = ''' -/* - * QAPI/QMP schema introspection - * - * Copyright (C) 2015 Red Hat, Inc. - * - * 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. - * - */ -''' -h_comment = ''' -/* - * QAPI/QMP schema introspection - * - * Copyright (C) 2015 Red Hat, Inc. - * - * 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. - * - */ -''' - -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix, - 'qmp-introspect.c', 'qmp-introspect.h', - c_comment, h_comment) - -fdef.write(mcgen(''' -#include "qemu/osdep.h" -#include "%(prefix)sqmp-introspect.h" - -''', - prefix=prefix)) - -schema = QAPISchema(input_file) -gen = QAPISchemaGenIntrospectVisitor(opt_unmask) -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) -close_output(fdef, fdecl) +def gen_introspect(schema, output_dir, prefix, opt_unmask): + vis = QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) + schema.visit(vis) + vis.write(output_dir) diff --git a/scripts/qapi-types.py b/scripts/qapi/types.py index 7e3051dbb9..64d9c0fb37 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi/types.py @@ -1,17 +1,19 @@ -# -# QAPI types generator -# -# Copyright IBM, Corp. 2011 -# Copyright (c) 2013-2016 Red Hat Inc. -# -# Authors: -# Anthony Liguori <aliguori@us.ibm.com> -# Markus Armbruster <armbru@redhat.com> -# -# This work is licensed under the terms of the GNU GPL, version 2. +""" +QAPI types generator + +Copyright IBM, Corp. 2011 +Copyright (c) 2013-2018 Red Hat Inc. + +Authors: + Anthony Liguori <aliguori@us.ibm.com> + Michael Roth <mdroth@linux.vnet.ibm.com> + Markus Armbruster <armbru@redhat.com> + +This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. +""" -from qapi import * +from qapi.common import * # variants must be emitted before their container; track what has already @@ -165,67 +167,62 @@ void qapi_free_%(c_name)s(%(c_name)s *obj) return ret -class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): - def __init__(self): - self.decl = None - self.defn = None - self._fwdecl = None - self._btin = None +class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): + + def __init__(self, prefix): + QAPISchemaModularCVisitor.__init__( + self, prefix, 'qapi-types', ' * Schema-defined QAPI types', + __doc__) + self._add_module(None, ' * Built-in QAPI types') + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/dealloc-visitor.h" +#include "qapi/qapi-builtin-types.h" +#include "qapi/qapi-builtin-visit.h" +''')) + self._genh.preamble_add(mcgen(''' +#include "qapi/util.h" +''')) + + def _begin_module(self, name): + types = self._module_basename('qapi-types', name) + visit = self._module_basename('qapi-visit', name) + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qapi/dealloc-visitor.h" +#include "%(types)s.h" +#include "%(visit)s.h" +''', + types=types, visit=visit)) + self._genh.preamble_add(mcgen(''' +#include "qapi/qapi-builtin-types.h" +''')) def visit_begin(self, schema): # gen_object() is recursive, ensure it doesn't visit the empty type objects_seen.add(schema.the_empty_object_type.name) - self.decl = '' - self.defn = '' - self._fwdecl = '' - self._btin = guardstart('QAPI_TYPES_BUILTIN') - - def visit_end(self): - self.decl = self._fwdecl + self.decl - self._fwdecl = None - # To avoid header dependency hell, we always generate - # declarations for built-in types in our header files and - # simply guard them. See also do_builtins (command line - # option -b). - self._btin += guardend('QAPI_TYPES_BUILTIN') - self.decl = self._btin + self.decl - self._btin = None def _gen_type_cleanup(self, name): - self.decl += gen_type_cleanup_decl(name) - self.defn += gen_type_cleanup(name) + self._genh.add(gen_type_cleanup_decl(name)) + self._genc.add(gen_type_cleanup(name)) def visit_enum_type(self, name, info, values, prefix): - # Special case for our lone builtin enum type - # TODO use something cleaner than existence of info - if not info: - self._btin += gen_enum(name, values, prefix) - if do_builtins: - self.defn += gen_enum_lookup(name, values, prefix) - else: - self._fwdecl += gen_enum(name, values, prefix) - self.defn += gen_enum_lookup(name, values, prefix) + self._genh.preamble_add(gen_enum(name, values, prefix)) + self._genc.add(gen_enum_lookup(name, values, prefix)) def visit_array_type(self, name, info, element_type): - if isinstance(element_type, QAPISchemaBuiltinType): - self._btin += gen_fwd_object_or_array(name) - self._btin += gen_array(name, element_type) - self._btin += gen_type_cleanup_decl(name) - if do_builtins: - self.defn += gen_type_cleanup(name) - else: - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_array(name, element_type) - self._gen_type_cleanup(name) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_array(name, element_type)) + self._gen_type_cleanup(name) def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin if name == 'q_empty': return - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_object(name, base, members, variants) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_object(name, base, members, variants)) if base and not base.is_implicit(): - self.decl += gen_upcast(name, base) + self._genh.add(gen_upcast(name, base)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): @@ -233,73 +230,13 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): self._gen_type_cleanup(name) def visit_alternate_type(self, name, info, variants): - self._fwdecl += gen_fwd_object_or_array(name) - self.decl += gen_object(name, None, [variants.tag_member], variants) + self._genh.preamble_add(gen_fwd_object_or_array(name)) + self._genh.add(gen_object(name, None, + [variants.tag_member], variants)) self._gen_type_cleanup(name) -# If you link code generated from multiple schemata, you want only one -# instance of the code for built-in types. Generate it only when -# do_builtins, enabled by command line option -b. See also -# QAPISchemaGenTypeVisitor.visit_end(). -do_builtins = False - -(input_file, output_dir, do_c, do_h, prefix, opts) = \ - parse_command_line('b', ['builtins']) - -for o, a in opts: - if o in ('-b', '--builtins'): - do_builtins = True - -c_comment = ''' -/* - * deallocation functions for schema-defined QAPI types - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * Michael Roth <mdroth@linux.vnet.ibm.com> - * - * 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. - * - */ -''' -h_comment = ''' -/* - * schema-defined QAPI types - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * - * 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. - * - */ -''' - -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix, - 'qapi-types.c', 'qapi-types.h', - c_comment, h_comment) - -fdef.write(mcgen(''' -#include "qemu/osdep.h" -#include "qapi/dealloc-visitor.h" -#include "%(prefix)sqapi-types.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=prefix)) - -fdecl.write(mcgen(''' -#include "qapi/util.h" -''')) - -schema = QAPISchema(input_file) -gen = QAPISchemaGenTypeVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) -close_output(fdef, fdecl) +def gen_types(schema, output_dir, prefix, opt_builtins): + vis = QAPISchemaGenTypeVisitor(prefix) + schema.visit(vis) + vis.write(output_dir, opt_builtins) diff --git a/scripts/qapi-visit.py b/scripts/qapi/visit.py index 7e1cfc13f0..5d72d8936c 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi/visit.py @@ -1,18 +1,19 @@ -# -# QAPI visitor generator -# -# Copyright IBM, Corp. 2011 -# Copyright (C) 2014-2016 Red Hat, Inc. -# -# Authors: -# Anthony Liguori <aliguori@us.ibm.com> -# Michael Roth <mdroth@linux.vnet.ibm.com> -# Markus Armbruster <armbru@redhat.com> -# -# This work is licensed under the terms of the GNU GPL, version 2. -# See the COPYING file in the top-level directory. - -from qapi import * +""" +QAPI visitor generator + +Copyright IBM, Corp. 2011 +Copyright (C) 2014-2018 Red Hat, Inc. + +Authors: + Anthony Liguori <aliguori@us.ibm.com> + Michael Roth <mdroth@linux.vnet.ibm.com> + Markus Armbruster <armbru@redhat.com> + +This work is licensed under the terms of the GNU GPL, version 2. +See the COPYING file in the top-level directory. +""" + +from qapi.common import * def gen_visit_decl(name, scalar=False): @@ -262,131 +263,71 @@ out: c_name=c_name(name)) -class QAPISchemaGenVisitVisitor(QAPISchemaVisitor): - def __init__(self): - self.decl = None - self.defn = None - self._btin = None +class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): + + def __init__(self, prefix): + QAPISchemaModularCVisitor.__init__( + self, prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', + __doc__) + self._add_module(None, ' * Built-in QAPI visitors') + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi/qapi-builtin-visit.h" +''')) + self._genh.preamble_add(mcgen(''' +#include "qapi/visitor.h" +#include "qapi/qapi-builtin-types.h" + +''', + prefix=prefix)) - def visit_begin(self, schema): - self.decl = '' - self.defn = '' - self._btin = guardstart('QAPI_VISIT_BUILTIN') + def _begin_module(self, name): + types = self._module_basename('qapi-types', name) + visit = self._module_basename('qapi-visit', name) + self._genc.preamble_add(mcgen(''' +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "%(visit)s.h" +''', + visit=visit, prefix=self._prefix)) + self._genh.preamble_add(mcgen(''' +#include "qapi/qapi-builtin-visit.h" +#include "%(types)s.h" - def visit_end(self): - # To avoid header dependency hell, we always generate - # declarations for built-in types in our header files and - # simply guard them. See also do_builtins (command line - # option -b). - self._btin += guardend('QAPI_VISIT_BUILTIN') - self.decl = self._btin + self.decl - self._btin = None +''', + types=types)) def visit_enum_type(self, name, info, values, prefix): - # Special case for our lone builtin enum type - # TODO use something cleaner than existence of info - if not info: - self._btin += gen_visit_decl(name, scalar=True) - if do_builtins: - self.defn += gen_visit_enum(name) - else: - self.decl += gen_visit_decl(name, scalar=True) - self.defn += gen_visit_enum(name) + self._genh.add(gen_visit_decl(name, scalar=True)) + self._genc.add(gen_visit_enum(name)) def visit_array_type(self, name, info, element_type): - decl = gen_visit_decl(name) - defn = gen_visit_list(name, element_type) - if isinstance(element_type, QAPISchemaBuiltinType): - self._btin += decl - if do_builtins: - self.defn += defn - else: - self.decl += decl - self.defn += defn + self._genh.add(gen_visit_decl(name)) + self._genc.add(gen_visit_list(name, element_type)) def visit_object_type(self, name, info, base, members, variants): # Nothing to do for the special empty builtin if name == 'q_empty': return - self.decl += gen_visit_members_decl(name) - self.defn += gen_visit_object_members(name, base, members, variants) + self._genh.add(gen_visit_members_decl(name)) + self._genc.add(gen_visit_object_members(name, base, members, variants)) # TODO Worth changing the visitor signature, so we could # directly use rather than repeat type.is_implicit()? if not name.startswith('q_'): # only explicit types need an allocating visit - self.decl += gen_visit_decl(name) - self.defn += gen_visit_object(name, base, members, variants) + self._genh.add(gen_visit_decl(name)) + self._genc.add(gen_visit_object(name, base, members, variants)) def visit_alternate_type(self, name, info, variants): - self.decl += gen_visit_decl(name) - self.defn += gen_visit_alternate(name, variants) - -# If you link code generated from multiple schemata, you want only one -# instance of the code for built-in types. Generate it only when -# do_builtins, enabled by command line option -b. See also -# QAPISchemaGenVisitVisitor.visit_end(). -do_builtins = False - -(input_file, output_dir, do_c, do_h, prefix, opts) = \ - parse_command_line('b', ['builtins']) - -for o, a in opts: - if o in ('-b', '--builtins'): - do_builtins = True - -c_comment = ''' -/* - * schema-defined QAPI visitor functions - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * - * 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. - * - */ -''' -h_comment = ''' -/* - * schema-defined QAPI visitor functions - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori <aliguori@us.ibm.com> - * - * 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. - * - */ -''' - -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix, - 'qapi-visit.c', 'qapi-visit.h', - c_comment, h_comment) - -fdef.write(mcgen(''' -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qapi/error.h" -#include "%(prefix)sqapi-visit.h" -''', - prefix=prefix)) - -fdecl.write(mcgen(''' -#include "qapi/visitor.h" -#include "qapi/qmp/qerror.h" -#include "%(prefix)sqapi-types.h" - -''', - prefix=prefix)) + self._genh.add(gen_visit_decl(name)) + self._genc.add(gen_visit_alternate(name, variants)) -schema = QAPISchema(input_file) -gen = QAPISchemaGenVisitVisitor() -schema.visit(gen) -fdef.write(gen.defn) -fdecl.write(gen.decl) -close_output(fdef, fdecl) +def gen_visit(schema, output_dir, prefix, opt_builtins): + vis = QAPISchemaGenVisitVisitor(prefix) + schema.visit(vis) + vis.write(output_dir, opt_builtins) diff --git a/stubs/tpm.c b/stubs/tpm.c index c18aac1c73..6729bc8517 100644 --- a/stubs/tpm.c +++ b/stubs/tpm.c @@ -4,9 +4,10 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ + #include "qemu/osdep.h" +#include "qapi/qapi-commands-tpm.h" #include "sysemu/tpm.h" -#include "qmp-commands.h" int tpm_init(void) { diff --git a/stubs/uuid.c b/stubs/uuid.c index a880de8d61..a802e9836b 100644 --- a/stubs/uuid.c +++ b/stubs/uuid.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/uuid.h" -#include "qmp-commands.h" UuidInfo *qmp_query_uuid(Error **errp) { diff --git a/stubs/vmgenid.c b/stubs/vmgenid.c index 3c8fe55bdf..568e42b064 100644 --- a/stubs/vmgenid.c +++ b/stubs/vmgenid.c @@ -1,6 +1,6 @@ #include "qemu/osdep.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qerror.h" GuidInfo *qmp_query_vm_generation_id(Error **errp) diff --git a/stubs/xen-hvm.c b/stubs/xen-hvm.c index 3ca6c51b21..0067bcc6db 100644 --- a/stubs/xen-hvm.c +++ b/stubs/xen-hvm.c @@ -12,7 +12,7 @@ #include "qemu-common.h" #include "hw/xen/xen.h" #include "exec/memory.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands-misc.h" int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) { diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 299cb80ae7..4cdd2676dd 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -19,10 +19,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + #include "qemu/osdep.h" -#include "qmp-commands.h" #include "hw/boards.h" #include "kvm_arm.h" +#include "qapi/qapi-commands-misc.h" static GICCapability *gic_cap_new(int version) { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b5e431e769..2c04645cea 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -31,10 +31,10 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qapi/error.h" +#include "qapi/qapi-visit-misc.h" +#include "qapi/qapi-visit-run-state.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" - -#include "qapi-visit.h" #include "qapi/visitor.h" #include "qom/qom-qobject.h" #include "sysemu/arch_init.h" diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 627002b225..c2b775f4eb 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -35,7 +35,8 @@ #include "qemu/error-report.h" #include "trace.h" #include "qapi/visitor.h" -#include "qapi-visit.h" +#include "qapi/qapi-visit-misc.h" +#include "qapi/qapi-visit-run-state.h" #include "sysemu/hw_accel.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 656aaea2cd..f570896dc1 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -41,7 +41,6 @@ #include "exec/gdbstub.h" #include "exec/address-spaces.h" #include "trace.h" -#include "qapi-event.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h" #include "hw/s390x/ipl.h" diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 5a7a9c4cfb..aff1530c82 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -17,6 +17,7 @@ #include "exec/exec-all.h" #include "sysemu/sysemu.h" #include "trace.h" +#include "qapi/qapi-types-misc.h" QemuMutex qemu_sigp_mutex; diff --git a/tests/.gitignore b/tests/.gitignore index e5c744b7ed..18e58b2183 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -60,7 +60,8 @@ test-keyval test-logging test-mul64 test-opts-visitor -test-qapi-event.[ch] +test-qapi-commands.[ch] +test-qapi-events.[ch] test-qapi-types.[ch] test-qapi-util test-qapi-visit.[ch] @@ -70,13 +71,11 @@ test-qdist test-qga test-qht test-qht-par -test-qmp-commands -test-qmp-commands.h +test-qmp-cmds test-qmp-event test-qobject-input-strict test-qobject-input-visitor -test-qmp-introspect.[ch] -test-qmp-marshal.c +test-qapi-introspect.[ch] test-qobject-output-visitor test-rcu-list test-replication diff --git a/tests/Makefile.include b/tests/Makefile.include index 937cbd874a..fdca062591 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -23,7 +23,16 @@ check-help: ifneq ($(wildcard config-host.mak),) export SRC_PATH -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py +# TODO don't duplicate $(SRC_PATH)/Makefile's qapi-py here +qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \ +$(SRC_PATH)/scripts/qapi/events.py \ +$(SRC_PATH)/scripts/qapi/introspect.py \ +$(SRC_PATH)/scripts/qapi/types.py \ +$(SRC_PATH)/scripts/qapi/visit.py \ +$(SRC_PATH)/scripts/qapi/common.py \ +$(SRC_PATH)/scripts/qapi/doc.py \ +$(SRC_PATH)/scripts/ordereddict.py \ +$(SRC_PATH)/scripts/qapi-gen.py # Get the list of all supported sysemu targets SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \ @@ -52,8 +61,8 @@ check-unit-y += tests/test-clone-visitor$(EXESUF) gcov-files-test-clone-visitor-y = qapi/qapi-clone-visitor.c check-unit-y += tests/test-qobject-input-visitor$(EXESUF) gcov-files-test-qobject-input-visitor-y = qapi/qobject-input-visitor.c -check-unit-y += tests/test-qmp-commands$(EXESUF) -gcov-files-test-qmp-commands-y = qapi/qmp-dispatch.c +check-unit-y += tests/test-qmp-cmds$(EXESUF) +gcov-files-test-qmp-cmds-y = qapi/qmp-dispatch.c check-unit-y += tests/test-string-input-visitor$(EXESUF) gcov-files-test-string-input-visitor-y = qapi/string-input-visitor.c check-unit-y += tests/test-string-output-visitor$(EXESUF) @@ -561,8 +570,8 @@ qapi-schema += unknown-expr-key.json check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema)) GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \ - tests/test-qmp-commands.h tests/test-qapi-event.h \ - tests/test-qmp-introspect.h + tests/test-qapi-commands.h tests/test-qapi-events.h \ + tests/test-qapi-introspect.h test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ tests/check-qlist.o tests/check-qnull.o tests/check-qobject.o \ @@ -571,7 +580,7 @@ test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \ tests/test-string-input-visitor.o tests/test-qobject-output-visitor.o \ tests/test-clone-visitor.o \ tests/test-qobject-input-visitor.o \ - tests/test-qmp-commands.o tests/test-visitor-serialization.o \ + tests/test-qmp-cmds.o tests/test-visitor-serialization.o \ tests/test-x86-cpuid.o tests/test-mul64.o tests/test-int128.o \ tests/test-opts-visitor.o tests/test-qmp-event.o \ tests/rcutorture.o tests/test-rcu-list.o \ @@ -587,7 +596,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests test-util-obj-y = libqemuutil.a test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y) test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \ - tests/test-qapi-event.o tests/test-qmp-introspect.o \ + tests/test-qapi-events.o tests/test-qapi-introspect.o \ $(test-qom-obj-y) benchmark-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y) @@ -649,34 +658,24 @@ tests/test-logging$(EXESUF): tests/test-logging.o $(test-util-obj-y) tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \ $(test-block-obj-y) -tests/test-qapi-types.c tests/test-qapi-types.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o tests -p "test-" $<, \ +tests/test-qapi-types.c tests/test-qapi-types.h \ +tests/test-qapi-visit.c tests/test-qapi-visit.h \ +tests/test-qapi-commands.h tests/test-qapi-commands.c \ +tests/test-qapi-events.c tests/test-qapi-events.h \ +tests/test-qapi-introspect.c tests/test-qapi-introspect.h: \ +tests/test-qapi-gen-timestamp ; +tests/test-qapi-gen-timestamp: $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o tests -p "test-" $<, \ + "GEN","$(@:%-timestamp=%)") + @>$@ + +tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \ + -o tests/qapi-schema -p "doc-good-" $<, \ "GEN","$@") -tests/test-qapi-visit.c tests/test-qapi-visit.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qmp-commands.h tests/test-qmp-marshal.c :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qapi-event.c tests/test-qapi-event.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-event.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") -tests/test-qmp-introspect.c tests/test-qmp-introspect.h :\ -$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \ - $(gen-out-type) -o tests -p "test-" $<, \ - "GEN","$@") - -tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@") + @mv tests/qapi-schema/doc-good-qapi-doc.texi $@ + @rm -f tests/qapi-schema/doc-good-qapi-*.[ch] tests/qapi-schema/doc-good-qmp-*.[ch] tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) @@ -684,7 +683,7 @@ tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y) tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y) tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y) -tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y) +tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-commands.o $(test-qapi-obj-y) tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y) tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-obj-y) @@ -954,6 +953,7 @@ check-clean: $(MAKE) -C tests/tcg clean rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y) rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y)) + rm -f tests/test-qapi-gen-timestamp clean: check-clean diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 17e652535c..8d2f1ce8a2 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,5 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module comments.json enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-bad-section.out index 089bde1381..cd28721568 100644 --- a/tests/qapi-schema/doc-bad-section.out +++ b/tests/qapi-schema/doc-bad-section.out @@ -1,7 +1,8 @@ -enum Enum ['one', 'two'] +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -object q_empty +module doc-bad-section.json +enum Enum ['one', 'two'] doc symbol=Enum body= == Produces *invalid* texinfo diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 1d2c250527..430b5a87db 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -1,35 +1,36 @@ +object q_empty +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +module doc-good.json +enum Enum ['one', 'two'] object Base member base1: Enum optional=False -enum Enum ['one', 'two'] +object Variant1 + member var1: str optional=False +object Variant2 object Object base Base tag base1 case one: Variant1 case two: Variant2 -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] - prefix QTYPE +object q_obj_Variant1-wrapper + member data: Variant1 optional=False +object q_obj_Variant2-wrapper + member data: Variant2 optional=False +enum SugaredUnionKind ['one', 'two'] object SugaredUnion member type: SugaredUnionKind optional=False tag type case one: q_obj_Variant1-wrapper case two: q_obj_Variant2-wrapper -enum SugaredUnionKind ['one', 'two'] -object Variant1 - member var1: str optional=False -object Variant2 -command cmd q_obj_cmd-arg -> Object - gen=True success_response=True boxed=False -command cmd-boxed Object -> None - gen=True success_response=True boxed=True -object q_empty -object q_obj_Variant1-wrapper - member data: Variant1 optional=False -object q_obj_Variant2-wrapper - member data: Variant2 optional=False object q_obj_cmd-arg member arg1: int optional=False member arg2: str optional=True member arg3: bool optional=False +command cmd q_obj_cmd-arg -> Object + gen=True success_response=True boxed=False +command cmd-boxed Object -> None + gen=True success_response=True boxed=True doc freeform body= = Section diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi index 1778312581..0aed2300a5 100644 --- a/tests/qapi-schema/doc-good.texi +++ b/tests/qapi-schema/doc-good.texi @@ -1,3 +1,5 @@ +@c AUTOMATICALLY GENERATED, DO NOT MODIFY + @section Section @subsection Subsection @@ -231,4 +233,3 @@ If you're bored enough to read this, go see a video of boxed cats @end deftypefn - diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 40b886ddae..0ec234eec4 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,3 +1,3 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -object q_empty diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-case.out index 313c0fe7be..88c0964917 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,5 +1,6 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module event-case.json event oops None boxed=False -object q_empty diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/ident-with-escape.out index b5637cb2e0..ee3b34e623 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -1,7 +1,8 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE -command fooA q_obj_fooA-arg -> None - gen=True success_response=True boxed=False -object q_empty +module ident-with-escape.json object q_obj_fooA-arg member bar1: str optional=False +command fooA q_obj_fooA-arg -> None + gen=True success_response=True boxed=False diff --git a/tests/qapi-schema/include-no-file.err b/tests/qapi-schema/include-no-file.err index d5b9b22d85..e42bcf4bc1 100644 --- a/tests/qapi-schema/include-no-file.err +++ b/tests/qapi-schema/include-no-file.err @@ -1 +1 @@ -tests/qapi-schema/include-no-file.json:1: No such file or directory: include-no-file-sub.json +tests/qapi-schema/include-no-file.json:1: No such file or directory: tests/qapi-schema/include-no-file-sub.json diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out index 17e652535c..ebbabd7a18 100644 --- a/tests/qapi-schema/include-relpath.out +++ b/tests/qapi-schema/include-relpath.out @@ -1,4 +1,9 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-relpath.json +include include/relpath.json +module include/relpath.json +include include-relpath-sub.json +module include-relpath-sub.json enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out index 17e652535c..7235e055bc 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,14 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-repetition.json +include comments.json +module comments.json enum Status ['good', 'bad', 'ugly'] -object q_empty +module include-repetition.json +include include-repetition-sub.json +module include-repetition-sub.json +include comments.json +include comments.json +module include-repetition.json +include comments.json diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/include-simple.out index 17e652535c..006f723eeb 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,7 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module include-simple.json +include include-simple-sub.json +module include-simple-sub.json enum Status ['good', 'bad', 'ugly'] -object q_empty diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indented-expr.out index 586795f44d..a79935e8c3 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,7 +1,8 @@ +object q_empty enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE +module indented-expr.json command eins None -> None gen=True success_response=True boxed=False -object q_empty command zwei None -> None gen=True success_response=True boxed=False diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index 3b1e9082d3..012e7fc06a 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,87 +1,130 @@ -alternate AltEnumBool - tag type - case e: EnumOne - case b: bool -alternate AltEnumInt - tag type - case e: EnumOne - case i: int -alternate AltEnumNum - tag type - case e: EnumOne - case n: number -alternate AltNumEnum - tag type - case n: number - case e: EnumOne -alternate AltStrObj - tag type - case s: str - case o: TestStruct -event EVENT_A None - boxed=False -event EVENT_B None - boxed=False -event EVENT_C q_obj_EVENT_C-arg - boxed=False -event EVENT_D q_obj_EVENT_D-arg - boxed=False -event EVENT_E UserDefZero - boxed=True -event EVENT_F UserDefAlternate - boxed=True -object Empty1 -object Empty2 - base Empty1 -enum EnumOne ['value1', 'value2', 'value3'] -object EventStructOne - member struct1: UserDefOne optional=False +object q_empty +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] + prefix QTYPE +module qapi-schema-test.json +object TestStruct + member integer: int optional=False + member boolean: bool optional=False member string: str optional=False - member enum2: EnumOne optional=True -object ForceArrays - member unused1: UserDefOneList optional=False - member unused2: UserDefTwoList optional=False - member unused3: TestStructList optional=False -enum MyEnum [] object NestedEnumsOne member enum1: EnumOne optional=False member enum2: EnumOne optional=True member enum3: EnumOne optional=False member enum4: EnumOne optional=True +enum MyEnum [] +object Empty1 +object Empty2 + base Empty1 +command user_def_cmd0 Empty2 -> Empty2 + gen=True success_response=True boxed=False enum QEnumTwo ['value1', 'value2'] prefix QENUM_TWO -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] - prefix QTYPE -object TestStruct +object UserDefOne + base UserDefZero + member string: str optional=False + member enum1: EnumOne optional=True +enum EnumOne ['value1', 'value2', 'value3'] +object UserDefZero member integer: int optional=False - member boolean: bool optional=False +object UserDefTwoDictDict + member userdef: UserDefOne optional=False member string: str optional=False +object UserDefTwoDict + member string1: str optional=False + member dict2: UserDefTwoDictDict optional=False + member dict3: UserDefTwoDictDict optional=True +object UserDefTwo + member string0: str optional=False + member dict1: UserDefTwoDict optional=False +object ForceArrays + member unused1: UserDefOneList optional=False + member unused2: UserDefTwoList optional=False + member unused3: TestStructList optional=False object UserDefA member boolean: bool optional=False member a_b: int optional=True -alternate UserDefAlternate - tag type - case udfu: UserDefFlatUnion - case e: EnumOne - case i: int - case n: null object UserDefB member intb: int optional=False member a-b: bool optional=True -object UserDefC - member string1: str optional=False - member string2: str optional=False object UserDefFlatUnion base UserDefUnionBase tag enum1 case value1: UserDefA case value2: UserDefB case value3: UserDefB +object UserDefUnionBase + base UserDefZero + member string: str optional=False + member enum1: EnumOne optional=False +object q_obj_UserDefFlatUnion2-base + member integer: int optional=True + member string: str optional=False + member enum1: QEnumTwo optional=False object UserDefFlatUnion2 base q_obj_UserDefFlatUnion2-base tag enum1 case value1: UserDefC case value2: UserDefB +object WrapAlternate + member alt: UserDefAlternate optional=False +alternate UserDefAlternate + tag type + case udfu: UserDefFlatUnion + case e: EnumOne + case i: int + case n: null +object UserDefC + member string1: str optional=False + member string2: str optional=False +alternate AltEnumBool + tag type + case e: EnumOne + case b: bool +alternate AltEnumNum + tag type + case e: EnumOne + case n: number +alternate AltNumEnum + tag type + case n: number + case e: EnumOne +alternate AltEnumInt + tag type + case e: EnumOne + case i: int +alternate AltStrObj + tag type + case s: str + case o: TestStruct +object q_obj_intList-wrapper + member data: intList optional=False +object q_obj_int8List-wrapper + member data: int8List optional=False +object q_obj_int16List-wrapper + member data: int16List optional=False +object q_obj_int32List-wrapper + member data: int32List optional=False +object q_obj_int64List-wrapper + member data: int64List optional=False +object q_obj_uint8List-wrapper + member data: uint8List optional=False +object q_obj_uint16List-wrapper + member data: uint16List optional=False +object q_obj_uint32List-wrapper + member data: uint32List optional=False +object q_obj_uint64List-wrapper + member data: uint64List optional=False +object q_obj_numberList-wrapper + member data: numberList optional=False +object q_obj_boolList-wrapper + member data: boolList optional=False +object q_obj_strList-wrapper + member data: strList optional=False +object q_obj_sizeList-wrapper + member data: sizeList optional=False +object q_obj_anyList-wrapper + member data: anyList optional=False +enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] object UserDefNativeListUnion member type: UserDefNativeListUnionKind optional=False tag type @@ -99,133 +142,91 @@ object UserDefNativeListUnion case string: q_obj_strList-wrapper case sizes: q_obj_sizeList-wrapper case any: q_obj_anyList-wrapper -enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8', 'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any'] -object UserDefOne - base UserDefZero - member string: str optional=False - member enum1: EnumOne optional=True +command user_def_cmd None -> None + gen=True success_response=True boxed=False +object q_obj_user_def_cmd1-arg + member ud1a: UserDefOne optional=False +command user_def_cmd1 q_obj_user_def_cmd1-arg -> None + gen=True success_response=True boxed=False +object q_obj_user_def_cmd2-arg + member ud1a: UserDefOne optional=False + member ud1b: UserDefOne optional=True +command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo + gen=True success_response=True boxed=False +object q_obj_guest-get-time-arg + member a: int optional=False + member b: int optional=True +command guest-get-time q_obj_guest-get-time-arg -> int + gen=True success_response=True boxed=False +object q_obj_guest-sync-arg + member arg: any optional=False +command guest-sync q_obj_guest-sync-arg -> any + gen=True success_response=True boxed=False +command boxed-struct UserDefZero -> None + gen=True success_response=True boxed=True +command boxed-union UserDefNativeListUnion -> None + gen=True success_response=True boxed=True object UserDefOptions member i64: intList optional=True member u64: uint64List optional=True member u16: uint16List optional=True member i64x: int optional=True member u64x: uint64 optional=True -object UserDefTwo - member string0: str optional=False - member dict1: UserDefTwoDict optional=False -object UserDefTwoDict - member string1: str optional=False - member dict2: UserDefTwoDictDict optional=False - member dict3: UserDefTwoDictDict optional=True -object UserDefTwoDictDict - member userdef: UserDefOne optional=False - member string: str optional=False -object UserDefUnionBase - base UserDefZero +object EventStructOne + member struct1: UserDefOne optional=False member string: str optional=False - member enum1: EnumOne optional=False -object UserDefZero - member integer: int optional=False -object WrapAlternate - member alt: UserDefAlternate optional=False -event __ORG.QEMU_X-EVENT __org.qemu_x-Struct + member enum2: EnumOne optional=True +event EVENT_A None boxed=False -alternate __org.qemu_x-Alt - tag type - case __org.qemu_x-branch: str - case b: __org.qemu_x-Base +event EVENT_B None + boxed=False +object q_obj_EVENT_C-arg + member a: int optional=True + member b: UserDefOne optional=True + member c: str optional=False +event EVENT_C q_obj_EVENT_C-arg + boxed=False +object q_obj_EVENT_D-arg + member a: EventStructOne optional=False + member b: str optional=False + member c: str optional=True + member enum3: EnumOne optional=True +event EVENT_D q_obj_EVENT_D-arg + boxed=False +event EVENT_E UserDefZero + boxed=True +event EVENT_F UserDefAlternate + boxed=True +enum __org.qemu_x-Enum ['__org.qemu_x-value'] object __org.qemu_x-Base member __org.qemu_x-member1: __org.qemu_x-Enum optional=False -enum __org.qemu_x-Enum ['__org.qemu_x-value'] object __org.qemu_x-Struct base __org.qemu_x-Base member __org.qemu_x-member2: str optional=False member wchar-t: int optional=True -object __org.qemu_x-Struct2 - member array: __org.qemu_x-Union1List optional=False +object q_obj_str-wrapper + member data: str optional=False +enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch'] object __org.qemu_x-Union1 member type: __org.qemu_x-Union1Kind optional=False tag type case __org.qemu_x-branch: q_obj_str-wrapper -enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch'] +object __org.qemu_x-Struct2 + member array: __org.qemu_x-Union1List optional=False object __org.qemu_x-Union2 base __org.qemu_x-Base tag __org.qemu_x-member1 case __org.qemu_x-value: __org.qemu_x-Struct2 -command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_x-Union1 - gen=True success_response=True boxed=False -command boxed-struct UserDefZero -> None - gen=True success_response=True boxed=True -command boxed-union UserDefNativeListUnion -> None - gen=True success_response=True boxed=True -command guest-get-time q_obj_guest-get-time-arg -> int - gen=True success_response=True boxed=False -command guest-sync q_obj_guest-sync-arg -> any - gen=True success_response=True boxed=False -object q_empty -object q_obj_EVENT_C-arg - member a: int optional=True - member b: UserDefOne optional=True - member c: str optional=False -object q_obj_EVENT_D-arg - member a: EventStructOne optional=False - member b: str optional=False - member c: str optional=True - member enum3: EnumOne optional=True -object q_obj_UserDefFlatUnion2-base - member integer: int optional=True - member string: str optional=False - member enum1: QEnumTwo optional=False +alternate __org.qemu_x-Alt + tag type + case __org.qemu_x-branch: str + case b: __org.qemu_x-Base +event __ORG.QEMU_X-EVENT __org.qemu_x-Struct + boxed=False object q_obj___org.qemu_x-command-arg member a: __org.qemu_x-EnumList optional=False member b: __org.qemu_x-StructList optional=False member c: __org.qemu_x-Union2 optional=False member d: __org.qemu_x-Alt optional=False -object q_obj_anyList-wrapper - member data: anyList optional=False -object q_obj_boolList-wrapper - member data: boolList optional=False -object q_obj_guest-get-time-arg - member a: int optional=False - member b: int optional=True -object q_obj_guest-sync-arg - member arg: any optional=False -object q_obj_int16List-wrapper - member data: int16List optional=False -object q_obj_int32List-wrapper - member data: int32List optional=False -object q_obj_int64List-wrapper - member data: int64List optional=False -object q_obj_int8List-wrapper - member data: int8List optional=False -object q_obj_intList-wrapper - member data: intList optional=False -object q_obj_numberList-wrapper - member data: numberList optional=False -object q_obj_sizeList-wrapper - member data: sizeList optional=False -object q_obj_str-wrapper - member data: str optional=False -object q_obj_strList-wrapper - member data: strList optional=False -object q_obj_uint16List-wrapper - member data: uint16List optional=False -object q_obj_uint32List-wrapper - member data: uint32List optional=False -object q_obj_uint64List-wrapper - member data: uint64List optional=False -object q_obj_uint8List-wrapper - member data: uint8List optional=False -object q_obj_user_def_cmd1-arg - member ud1a: UserDefOne optional=False -object q_obj_user_def_cmd2-arg - member ud1a: UserDefOne optional=False - member ud1b: UserDefOne optional=True -command user_def_cmd None -> None - gen=True success_response=True boxed=False -command user_def_cmd0 Empty2 -> Empty2 - gen=True success_response=True boxed=False -command user_def_cmd1 q_obj_user_def_cmd1-arg -> None - gen=True success_response=True boxed=False -command user_def_cmd2 q_obj_user_def_cmd2-arg -> UserDefTwo +command __org.qemu_x-command q_obj___org.qemu_x-command-arg -> __org.qemu_x-Union1 gen=True success_response=True boxed=False diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index ac43d3458e..67e417e298 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -11,13 +11,18 @@ # from __future__ import print_function -from qapi import * -from pprint import pprint -import os import sys +from qapi.common import QAPIError, QAPISchema, QAPISchemaVisitor class QAPISchemaTestVisitor(QAPISchemaVisitor): + + def visit_module(self, name): + print('module %s' % name) + + def visit_include(self, name, info): + print('include %s' % name) + def visit_enum_type(self, name, info, values, prefix): print('enum %s %s' % (name, values)) if prefix: @@ -54,7 +59,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor): for v in variants.variants: print(' case %s: %s' % (v.name, v.type.name)) -schema = QAPISchema(sys.argv[1]) + +try: + schema = QAPISchema(sys.argv[1]) +except QAPIError as err: + print(err, file=sys.stderr) + exit(1) + schema.visit(QAPISchemaTestVisitor()) for doc in schema.docs: diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 580848307a..22445d9ec2 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -12,8 +12,9 @@ #include "qemu/osdep.h" #include "libqtest.h" -#include "qapi-visit.h" #include "qapi/error.h" +#include "qapi/qapi-visit-introspect.h" +#include "qapi/qapi-visit-misc.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qapi/qobject-input-visitor.h" diff --git a/tests/test-char.c b/tests/test-char.c index b358620911..b3a77af085 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -8,9 +8,9 @@ #include "chardev/char-mux.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qapi/qapi-commands-char.h" #include "qapi/qmp/qdict.h" #include "qom/qom-qobject.h" -#include "qmp-commands.h" static bool quit; diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-cmds.c index 24660d0868..5b1cee6912 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-cmds.c @@ -3,12 +3,12 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" -#include "test-qmp-commands.h" #include "qapi/error.h" #include "qemu/module.h" #include "qapi/qobject-input-visitor.h" #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" +#include "test-qapi-commands.h" static QmpCommandList qmp_commands; diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 8012341343..31f35b3e66 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -14,14 +14,13 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "test-qapi-visit.h" -#include "test-qapi-event.h" #include "qapi/error.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp-event.h" +#include "test-qapi-events.h" typedef struct TestEventData { QDict *expect; diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index 3900be2610..79b1a8cb17 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -15,6 +15,7 @@ #include "qemu-common.h" #include "qapi/error.h" +#include "qapi/qapi-visit-introspect.h" #include "qapi/qobject-input-visitor.h" #include "test-qapi-visit.h" #include "qapi/qmp/qbool.h" @@ -23,9 +24,8 @@ #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "test-qmp-introspect.h" -#include "qmp-introspect.h" -#include "qapi-visit.h" +#include "test-qapi-introspect.h" +#include "qapi/qapi-introspect.h" typedef struct TestInputVisitorData { QObject *obj; @@ -1376,7 +1376,7 @@ int main(int argc, char **argv) NULL, test_visitor_in_fail_alternate); input_visitor_test_add("/visitor/input/fail/union-native-list", NULL, test_visitor_in_fail_union_native_list); - input_visitor_test_add("/visitor/input/qmp-introspect", + input_visitor_test_add("/visitor/input/qapi-introspect", NULL, test_visitor_in_qmp_introspect); g_test_run(); diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index dd7e51d4f5..438c18a0d6 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -23,7 +23,6 @@ #include "qapi/qobject-output-visitor.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" -#include "qapi-visit.h" #include "qapi/dealloc-visitor.h" enum PrimitiveTypeKind { @@ -15,12 +15,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-tpm.h" #include "qapi/qmp/qerror.h" #include "sysemu/tpm_backend.h" #include "sysemu/tpm.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "qmp-commands.h" static QLIST_HEAD(, TPMBackend) tpm_backends = QLIST_HEAD_INITIALIZER(tpm_backends); @@ -181,8 +181,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) } /* - * Walk the list of active TPM backends and collect information about them - * following the schema description in qapi-schema.json. + * Walk the list of active TPM backends and collect information about them. */ TPMInfoList *qmp_query_tpm(Error **errp) { diff --git a/trace/qmp.c b/trace/qmp.c index ccd35cd840..756086c79f 100644 --- a/trace/qmp.c +++ b/trace/qmp.c @@ -9,7 +9,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands-trace.h" #include "trace/control.h" diff --git a/ui/cocoa.m b/ui/cocoa.m index 90d9aa57ea..30888ca8fd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -32,7 +32,7 @@ #include "ui/input.h" #include "sysemu/sysemu.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands.h" #include "sysemu/blockdev.h" #include "qemu-version.h" #include <Carbon/Carbon.h> diff --git a/ui/console.c b/ui/console.c index e22931a396..6a1f49916e 100644 --- a/ui/console.c +++ b/ui/console.c @@ -26,9 +26,9 @@ #include "ui/console.h" #include "hw/qdev-core.h" #include "qapi/error.h" +#include "qapi/qapi-commands-ui.h" #include "qemu/option.h" #include "qemu/timer.h" -#include "qmp-commands.h" #include "chardev/char-fe.h" #include "trace.h" #include "exec/memory.h" @@ -37,6 +37,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qemu/cutils.h" #include "ui/console.h" @@ -52,7 +53,6 @@ #include "trace.h" #include "ui/input.h" #include "sysemu/sysemu.h" -#include "qmp-commands.h" #include "keymaps.h" #include "chardev/char.h" #include "qom/object.h" diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 92b37ccb90..e5d4db1d97 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -23,9 +23,9 @@ */ #include "qemu/osdep.h" +#include "qapi/qapi-commands-ui.h" #include "sysemu/sysemu.h" #include "ui/console.h" -#include "qmp-commands.h" #include "ui/keymaps.h" #include "ui/input.h" diff --git a/ui/input.c b/ui/input.c index 8bef0fb038..51b1019252 100644 --- a/ui/input.c +++ b/ui/input.c @@ -1,9 +1,9 @@ #include "qemu/osdep.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" #include "qemu/error-report.h" -#include "qmp-commands.h" #include "trace.h" #include "ui/input.h" #include "ui/console.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index e449172fe9..ae8921a201 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -28,14 +28,14 @@ #include "qemu/queue.h" #include "qemu-x509.h" #include "qemu/sockets.h" -#include "qmp-commands.h" #include "qapi/error.h" +#include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-events-ui.h" #include "qemu/notify.h" #include "qemu/option.h" #include "migration/misc.h" #include "hw/hw.h" #include "ui/spice-display.h" -#include "qapi-event.h" /* core bits */ @@ -35,10 +35,10 @@ #include "qemu/timer.h" #include "qemu/acl.h" #include "qemu/config-file.h" +#include "qapi/qapi-events.h" #include "qapi/error.h" -#include "qmp-commands.h" +#include "qapi/qapi-commands-ui.h" #include "ui/input.h" -#include "qapi-event.h" #include "crypto/hash.h" #include "crypto/tlscredsanon.h" #include "crypto/tlscredsx509.h" @@ -28,6 +28,7 @@ #define QEMU_VNC_H #include "qemu-common.h" +#include "qapi/qapi-types-ui.h" #include "qemu/queue.h" #include "qemu/thread.h" #include "ui/console.h" diff --git a/util/qemu-config.c b/util/qemu-config.c index 10cae120cc..c651c4826e 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -1,12 +1,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qemu-common.h" #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "qmp-commands.h" static QemuOptsList *vm_config_groups[48]; static QemuOptsList *drive_config_groups[5]; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index fbbef69f62..7f13e8a338 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -24,11 +24,11 @@ #include "monitor/monitor.h" #include "qapi/clone-visitor.h" #include "qapi/error.h" +#include "qapi/qapi-visit-sockets.h" #include "qemu/sockets.h" #include "qemu/main-loop.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" -#include "qapi-visit.h" #include "qemu/cutils.h" #ifndef AI_ADDRCONFIG @@ -97,11 +97,9 @@ int main(int argc, char **argv) #include "sysemu/kvm.h" #include "sysemu/hax.h" #include "qapi/qobject-input-visitor.h" -#include "qapi-visit.h" #include "qemu/option.h" #include "qemu/config-file.h" #include "qemu-options.h" -#include "qmp-commands.h" #include "qemu/main-loop.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" @@ -122,10 +120,14 @@ int main(int argc, char **argv) #include "qapi/string-input-visitor.h" #include "qapi/opts-visitor.h" #include "qom/object_interfaces.h" -#include "qapi-event.h" #include "exec/semihost.h" #include "crypto/init.h" #include "sysemu/replay.h" +#include "qapi/qapi-events-run-state.h" +#include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-run-state.h" #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" |