From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUITV-0001TE-86 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 10:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUITU-0005CY-29 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 10:43:57 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:49132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUITT-00052C-SQ for qemu-devel@nongnu.org; Fri, 02 Nov 2012 10:43:55 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so2443187pbb.4 for ; Fri, 02 Nov 2012 07:43:55 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 2 Nov 2012 15:43:24 +0100 Message-Id: <1351867404-25510-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1351867404-25510-1-git-send-email-pbonzini@redhat.com> References: <1351867404-25510-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 5/5] vl: delay thread initialization after daemonization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, jan.kiszka@siemens.com, peter.maydell@linaro.org 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 --- main-loop.c | 1 - vl.c | 4 +++- 2 file modificati, 3 inserzioni(+), 2 rimozioni(-) diff --git a/main-loop.c b/main-loop.c index 234a313..c87624e 100644 --- a/main-loop.c +++ b/main-loop.c @@ -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 e2d5276..0f5b07b 100644 --- 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(); -- 1.7.12.1