From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, jan.kiszka@siemens.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH 5/5] vl: delay thread initialization after daemonization
Date: Fri, 2 Nov 2012 14:14:07 +0100 [thread overview]
Message-ID: <1351862047-23172-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1351862047-23172-1-git-send-email-pbonzini@redhat.com>
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>
---
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
prev parent reply other threads:[~2012-11-02 13:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 13:14 [Qemu-devel] [PATCH 0/5] Fixes for thread pool patches Paolo Bonzini
2012-11-02 13:14 ` [Qemu-devel] [PATCH 1/5] compiler: support Darwin weak references Paolo Bonzini
2012-11-02 13:46 ` Peter Maydell
2012-11-02 13:14 ` [Qemu-devel] [PATCH 2/5] semaphore: implement fallback counting semaphores with mutex+condvar Paolo Bonzini
2012-11-02 13:50 ` Peter Maydell
2012-11-18 9:09 ` Brad Smith
2012-11-18 16:06 ` Paolo Bonzini
2012-11-27 2:56 ` Brad Smith
2012-11-02 13:14 ` [Qemu-devel] [PATCH 3/5] qemu-timer: reinitialize timers after fork Paolo Bonzini
2012-11-02 13:14 ` [Qemu-devel] [PATCH 4/5] vl: unify calls to init_timer_alarm Paolo Bonzini
2012-11-02 13:14 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351862047-23172-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).