]>
Commit | Line | Data |
---|---|---|
53e83913 WB |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> | |
3 | Date: Fri, 7 Sep 2018 14:45:51 +0200 | |
4 | Subject: [PATCH] monitor: create iothread after daemonizing | |
5 | ||
6 | Commit d32749deb615 moved the call to monitor_init_globals() | |
7 | to before os_daemonize() in order to initialize locks used | |
8 | when parsing arguments and instantiating monitors. | |
9 | This function also creates an iothread which is now lost | |
10 | when fork()ing in os_daemonize(), causing its final join to | |
11 | fail. | |
12 | Fix this by exposing monitor_iothread_init() to be used in | |
13 | vl.c after the os_daemonize() call. | |
14 | ||
15 | FIXME: verify nothing between the new init() place and | |
16 | iothread spawning actually already depends on the iothread. | |
17 | ||
18 | Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> | |
19 | Fixes: d32749deb615 ("monitor: move init global earlier") | |
20 | --- | |
21 | include/monitor/monitor.h | 1 + | |
22 | monitor.c | 3 +-- | |
23 | vl.c | 1 + | |
24 | 3 files changed, 3 insertions(+), 2 deletions(-) | |
25 | ||
26 | diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h | |
27 | index 2ef5e04b37..119c4a393e 100644 | |
28 | --- a/include/monitor/monitor.h | |
29 | +++ b/include/monitor/monitor.h | |
30 | @@ -18,6 +18,7 @@ extern __thread Monitor *cur_mon; | |
31 | bool monitor_cur_is_qmp(void); | |
32 | ||
33 | void monitor_init_globals(void); | |
34 | +void monitor_iothread_init(void); | |
35 | void monitor_init(Chardev *chr, int flags); | |
36 | void monitor_cleanup(void); | |
37 | ||
38 | diff --git a/monitor.c b/monitor.c | |
39 | index 77861e96af..24bfa0266b 100644 | |
40 | --- a/monitor.c | |
41 | +++ b/monitor.c | |
42 | @@ -4539,7 +4539,7 @@ static AioContext *monitor_get_aio_context(void) | |
43 | return iothread_get_aio_context(mon_iothread); | |
44 | } | |
45 | ||
46 | -static void monitor_iothread_init(void) | |
47 | +void monitor_iothread_init(void) | |
48 | { | |
49 | mon_iothread = iothread_create("mon_iothread", &error_abort); | |
50 | ||
51 | @@ -4569,7 +4569,6 @@ void monitor_init_globals(void) | |
52 | sortcmdlist(); | |
53 | qemu_mutex_init(&monitor_lock); | |
54 | qemu_mutex_init(&mon_fdsets_lock); | |
55 | - monitor_iothread_init(); | |
56 | } | |
57 | ||
58 | /* These functions just adapt the readline interface in a typesafe way. We | |
59 | diff --git a/vl.c b/vl.c | |
60 | index a03e4c2867..d96f4d0d2a 100644 | |
61 | --- a/vl.c | |
62 | +++ b/vl.c | |
63 | @@ -4008,6 +4008,7 @@ int main(int argc, char **argv, char **envp) | |
64 | ||
65 | os_daemonize(); | |
66 | rcu_disable_atfork(); | |
67 | + monitor_iothread_init(); | |
68 | ||
69 | if (pid_file && qemu_create_pidfile(pid_file) != 0) { | |
70 | error_report("could not acquire pid file: %s", strerror(errno)); | |
71 | -- | |
72 | 2.11.0 | |
73 |