qemu-e2k/qga
Markus Armbruster 0587568780 qmp: Dumb down how we run QMP command registration
The way we get QMP commands registered is high tech:

* qapi-commands.py generates qmp_init_marshal() that does the actual work

* it also generates the magic to register it as a MODULE_INIT_QAPI
  function, so it runs when someone calls
  module_call_init(MODULE_INIT_QAPI)

* main() calls module_call_init()

QEMU needs to register a few non-qapified commands.  Same high tech
works: monitor.c has its own qmp_init_marshal() along with the magic
to make it run in module_call_init(MODULE_INIT_QAPI).

QEMU also needs to unregister commands that are not wanted in this
build's configuration (commit 5032a16).  Simple enough:
qmp_unregister_commands_hack().  The difficulty is to make it run
after the generated qmp_init_marshal().  We can't simply run it in
monitor.c's qmp_init_marshal(), because the order in which the
registered functions run is indeterminate.  So qmp_init_marshal()
registers qmp_unregister_commands_hack() separately.  Since
registering *appends* to the list of registered functions, this will
make it run after all the functions that have been registered already.

I suspect it takes a long and expensive computer science education to
not find this silly.

Dumb it down as follows:

* Drop MODULE_INIT_QAPI entirely

* Give the generated qmp_init_marshal() external linkage.

* Call it instead of module_call_init(MODULE_INIT_QAPI)

* Except in QEMU proper, call new monitor_init_qmp_commands() that in
  turn calls the generated qmp_init_marshal(), registers the
  additional commands and unregisters the unwanted ones.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1488544368-30622-5-git-send-email-armbru@redhat.com>
2017-03-05 09:02:10 +01:00
..
installer qga: Workaround for console redirection from non-interactive qemu-ga service 2016-04-07 11:43:54 -05:00
vss-win32 rules.mak: quiet-command: Split command name and args to print 2016-10-06 12:11:51 +01:00
Makefile.objs qemu-ga: Call Windows VSS requester in fsfreeze command handler 2013-09-09 14:17:57 -05:00
channel-posix.c qga: add vsock-listen method 2016-10-31 19:49:33 -05:00
channel-win32.c qga: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
channel.h qga: add vsock-listen method 2016-10-31 19:49:33 -05:00
commands-posix.c coccinelle: Remove unnecessary variables for function return value 2016-06-20 16:38:13 +02:00
commands-win32.c qga: minimal support for fstrim for Windows guests 2016-10-31 19:09:21 -05:00
commands.c qga/command: use QEMU atomic primitives 2016-10-04 10:00:26 +02:00
guest-agent-command-state.c qga: free remaining leaking state 2016-09-08 17:57:32 +04:00
guest-agent-core.h qga: free remaining leaking state 2016-09-08 17:57:32 +04:00
main.c qmp: Dumb down how we run QMP command registration 2017-03-05 09:02:10 +01:00
qapi-schema.json qga/schema: improve guest-set-vcpus Returns: section 2017-01-16 09:15:24 +01:00
service-win32.c qga: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
service-win32.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
vss-win32.c qga: fix w32 breakage due to missing osdep.h includes 2016-02-25 10:54:32 -06:00
vss-win32.h all: Clean up includes 2016-02-23 12:43:05 +00:00