/qapi/qapi-emit-events.[ch]
/qapi/qapi-events-*.[ch]
/qapi/qapi-events.[ch]
+/qapi/qapi-init-commands.[ch]
/qapi/qapi-introspect.[ch]
/qapi/qapi-types-*.[ch]
/qapi/qapi-types.[ch]
GENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
+GENERATED_QAPI_FILES += qapi/qapi-init-commands.h qapi/qapi-init-commands.c
GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
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-init-commands.h qga/qapi-generated/qga-qapi-init-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)
"GEN","$(@:%-timestamp=%)")
@>$@
-QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h)
+QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h qga-qapi-init-commands.h)
$(qga-obj-y): $(QGALIB_GEN)
qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
$(prefix)qapi-commands.h: Function prototypes for the QMP commands
specified in the schema
+$(prefix)qapi-init-commands.h - Command initialization prototype
+
+$(prefix)qapi-init-commands.c - Command initialization code
+
Example:
$ cat qapi-generated/example-qapi-commands.h
#define EXAMPLE_QAPI_COMMANDS_H
#include "example-qapi-types.h"
- #include "qapi/qmp/dispatch.h"
UserDefOne *qmp_my_command(UserDefOneList *arg1, Error **errp);
void qmp_marshal_my_command(QDict *args, QObject **ret, Error **errp);
- void example_qmp_init_marshal(QmpCommandList *cmds);
#endif /* EXAMPLE_QAPI_COMMANDS_H */
$ cat qapi-generated/example-qapi-commands.c
visit_end_struct(v, NULL);
visit_free(v);
}
+[Uninteresting stuff omitted...]
+ $ cat qapi-generated/example-qapi-init-commands.h
+[Uninteresting stuff omitted...]
+ #ifndef EXAMPLE_QAPI_INIT_COMMANDS_H
+ #define EXAMPLE_QAPI_INIT_COMMANDS_H
+ #include "qapi/qmp/dispatch.h"
+
+ void example_qmp_init_marshal(QmpCommandList *cmds);
+
+ #endif /* EXAMPLE_QAPI_INIT_COMMANDS_H */
+ $ cat qapi-generated/example-qapi-init-commands.c
+[Uninteresting stuff omitted...]
void example_qmp_init_marshal(QmpCommandList *cmds)
{
QTAILQ_INIT(cmds);
qmp_register_command(cmds, "my-command",
qmp_marshal_my_command, QCO_NO_OPTIONS);
}
-
[Uninteresting stuff omitted...]
For a modular QAPI schema (see section Include directives), code for
#include "qemu/option.h"
#include "qemu/thread.h"
#include "block/qapi.h"
-#include "qapi/qapi-commands.h"
+#include "qapi/qapi-commands-char.h"
+#include "qapi/qapi-commands-migration.h"
+#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-qom.h"
+#include "qapi/qapi-commands-trace.h"
#include "qapi/qapi-emit-events.h"
+#include "qapi/qapi-init-commands.h"
#include "qapi/error.h"
#include "qapi/qmp-event.h"
#include "qapi/qapi-introspect.h"
obj-y += qapi-events.o
obj-y += $(QAPI_TARGET_MODULES:%=qapi-commands-%.o)
obj-y += qapi-commands.o
+obj-y += qapi-init-commands.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-qapi-commands.o
+qga-obj-y += qapi-generated/qga-qapi-init-commands.o
qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qstring.h"
#include "guest-agent-core.h"
-#include "qga-qapi-commands.h"
+#include "qga-qapi-init-commands.h"
#include "qapi/qmp/qerror.h"
#include "qapi/error.h"
#include "channel.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('''
+ self._add_system_module('init', ' * QAPI Commands initialization')
+ self._genh.add(mcgen('''
+#include "qapi/qmp/dispatch.h"
+
void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
''',
c_prefix=c_name(self._prefix, protect=False)))
- genc.add(gen_registry(self._regy.get_content(), self._prefix))
+ self._genc.preamble_add(mcgen('''
+#include "qemu/osdep.h"
+#include "%(prefix)sqapi-commands.h"
+#include "%(prefix)sqapi-init-commands.h"
+''',
+ prefix=self._prefix))
+ self._genc.add(gen_registry(self._regy.get_content(), self._prefix))
def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
success_response, boxed, allow_oob, allow_preconfig,
!test-*.c
!docker/test-*
test-qapi-commands.[ch]
+test-qapi-init-commands.[ch]
include/test-qapi-commands-sub-module.[ch]
test-qapi-commands-sub-sub-module.[ch]
test-qapi-emit-events.[ch]
generated-files-y += tests/include/test-qapi-visit-sub-module.h
generated-files-y += tests/test-qapi-visit-sub-sub-module.h
generated-files-y += tests/test-qapi-commands.h
+generated-files-y += tests/test-qapi-init-commands.h
generated-files-y += tests/include/test-qapi-commands-sub-module.h
generated-files-y += tests/test-qapi-commands-sub-sub-module.h
generated-files-y += tests/test-qapi-emit-events.h
tests/test-qapi-commands-sub-sub-module.c \
tests/test-qapi-emit-events.c tests/test-qapi-emit-events.h \
tests/test-qapi-events.c tests/test-qapi-events.h \
+tests/test-qapi-init-commands.c \
+tests/test-qapi-init-commands.h \
tests/include/test-qapi-events-sub-module.c \
tests/include/test-qapi-events-sub-module.h \
tests/test-qapi-events-sub-sub-module.c \
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-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-commands.o $(test-qapi-obj-y)
+tests/test-qmp-cmds$(EXESUF): tests/test-qmp-cmds.o tests/test-qapi-commands.o tests/test-qapi-init-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)
#include "tests/test-qapi-types.h"
#include "tests/test-qapi-visit.h"
#include "test-qapi-commands.h"
+#include "test-qapi-init-commands.h"
static QmpCommandList qmp_commands;