monitor: delay monitor iothread creation
commit8511770185f5769d06e7c3e37b2fd79f268cf84c
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 25 Sep 2018 08:15:07 +0000 (25 10:15 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 6 Nov 2018 16:02:49 +0000 (6 17:02 +0100)
tree685b15e70b8d986110cae990c81ec688e83f4013
parent9a3e52e3465f85d203d0fd2910ca3625b3c45420
monitor: delay monitor iothread creation

Commit d32749deb615 moved the call to monitor_init_globals()
to before os_daemonize(), making it an unsuitable place to
spawn the monitor iothread as it won't be inherited over the
fork() in os_daemonize().

We now spawn the thread the first time we instantiate a
monitor which actually has use_io_thread == true.
Instantiation of monitors happens only after os_daemonize().
We still need to create the qmp_dispatcher_bh when not using
iothreads, so this now still happens in
monitor_init_globals().

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: d32749deb615 ("monitor: move init global earlier")
Message-Id: <20180925081507.11873-3-w.bumiller@proxmox.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Tested-by: Peter Xu <peterx@redhat.com>
[This fixes a crash on shutdown with --daemonize]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
monitor.c