]> git.proxmox.com Git - qemu.git/commitdiff
vl: delay thread initialization after daemonization
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 2 Nov 2012 14:43:24 +0000 (15:43 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 2 Nov 2012 18:07:55 +0000 (13:07 -0500)
Commit ac4119c (chardev: Use timer instead of bottom-half to postpone
open event, 2012-10-12) moved the alarm timer initialization to an earlier
point but failed to consider that it depends on qemu_init_main_loop.

Later, commit 1c53786 (vl: init main loop earlier, 2012-10-30) fixed
this, but left -daemonize in two different ways.  First, timers need to
be reinitialized after forking.  Second, the global mutex was being held
by the parent, and thus dropped after forking.

The first is now fixed using pthread_atfork.  For the second part,
make sure that the global mutex is not taken before daemonization,
and similarly delay qemu_thread_self.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
main-loop.c
vl.c

index 234a3130c2132ad1c13322949549e14fffeb9ded..c87624e621680cff61af0f5b8450938495fe623d 100644 (file)
@@ -128,7 +128,6 @@ int qemu_init_main_loop(void)
         exit(1);
     }
 
-    qemu_mutex_lock_iothread();
     ret = qemu_signal_init();
     if (ret) {
         return ret;
diff --git a/vl.c b/vl.c
index e2d5276988e04c3ec9b53ab201ef87c221cf7a3f..0f5b07bbde67f29097367857dd3c22bda47134fa 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3477,7 +3477,6 @@ int main(int argc, char **argv, char **envp)
     }
     loc_set_none();
 
-    qemu_init_cpu_loop();
     if (qemu_init_main_loop()) {
         fprintf(stderr, "qemu_init_main_loop failed\n");
         exit(1);
@@ -3677,6 +3676,9 @@ int main(int argc, char **argv, char **envp)
 
     os_set_line_buffering();
 
+    qemu_init_cpu_loop();
+    qemu_mutex_lock_iothread();
+
 #ifdef CONFIG_SPICE
     /* spice needs the timers to be initialized by this point */
     qemu_spice_init();