Skip to content
  • Paolo Bonzini's avatar
    vl: delay thread initialization after daemonization · 49cf5728
    Paolo Bonzini authored
    Commit ac4119c0 (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 1c53786f
    
     (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: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
    49cf5728