qemu-irix/include/qemu
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
..
acl.h
atomic.h
base64.h
bcd.h
bitmap.h
bitops.h
bswap.h
buffer.h
compiler.h compiler: expression version of QEMU_BUILD_BUG_ON 2017-02-01 03:37:17 +02:00
config-file.h
coroutine.h coroutine-lock: make CoRwlock thread-safe and fair 2017-02-21 11:39:40 +00:00
coroutine_int.h aio: introduce aio_co_schedule and aio_co_wake 2017-02-21 11:14:07 +00:00
crc32c.h
cutils.h util/cutils: Change qemu_strtosz*() from int64_t to uint64_t 2017-02-23 20:35:36 +01:00
envlist.h
error-report.h
event_notifier.h
fifo8.h
fifo32.h
fprintf-fn.h
futex.h
hbitmap.h
help_option.h
host-utils.h
id.h
int128.h
iov.h
jhash.h
log.h
main-loop.h
memfd.h
mmap-alloc.h exec, kvm, target-ppc: Move getrampagesize() to common code 2017-03-03 11:30:59 +11:00
module.h qmp: Dumb down how we run QMP command registration 2017-03-05 09:02:10 +01:00
notify.h
option.h util: add iterators for QemuOpts values 2017-02-09 17:28:49 +01:00
option_int.h
osdep.h cpus: reorganize signal handling code 2017-03-03 16:40:02 +01:00
path.h
processor.h
qdist.h
qht.h
queue.h
range.h
ratelimit.h
rcu.h
rcu_queue.h
readline.h
seqlock.h
sockets.h
thread-posix.h
thread-win32.h
thread.h
throttle-options.h throttle: factor out duplicate code 2017-02-28 10:31:46 +01:00
throttle.h
timed-average.h
timer.h timer: use an inline function for free 2017-03-01 00:09:28 +04:00
typedefs.h
unicode.h
uri.h
uuid.h
xattr.h