Skip to content

Commit

Permalink
vl: delay thread initialization after daemonization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bonzini authored and Anthony Liguori committed Nov 2, 2012
1 parent f9ab465 commit 49cf572
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion main-loop.c
Expand Up @@ -128,7 +128,6 @@ int qemu_init_main_loop(void)
exit(1);
}

qemu_mutex_lock_iothread();
ret = qemu_signal_init();
if (ret) {
return ret;
Expand Down
4 changes: 3 additions & 1 deletion vl.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 49cf572

Please sign in to comment.