]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0005-monitor-create-iothread-after-daemonizing.patch
build qemu multithreaded
[pve-qemu.git] / debian / patches / extra / 0005-monitor-create-iothread-after-daemonizing.patch
CommitLineData
53e83913
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Fri, 7 Sep 2018 14:45:51 +0200
4Subject: [PATCH] monitor: create iothread after daemonizing
5
6Commit d32749deb615 moved the call to monitor_init_globals()
7to before os_daemonize() in order to initialize locks used
8when parsing arguments and instantiating monitors.
9This function also creates an iothread which is now lost
10when fork()ing in os_daemonize(), causing its final join to
11fail.
12Fix this by exposing monitor_iothread_init() to be used in
13vl.c after the os_daemonize() call.
14
15FIXME: verify nothing between the new init() place and
16iothread spawning actually already depends on the iothread.
17
18Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
19Fixes: 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
26diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
27index 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
38diff --git a/monitor.c b/monitor.c
39index 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
59diff --git a/vl.c b/vl.c
60index 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--
722.11.0
73