qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] stop cpus before forking.
@ 2010-06-14 19:27 Glauber Costa
  2010-06-14 19:33 ` Anthony Liguori
  0 siblings, 1 reply; 12+ messages in thread
From: Glauber Costa @ 2010-06-14 19:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, avi

This patch fixes a bug that happens with kvm, irqchip-in-kernel,
while adding a netdev. Despite the situations of reproduction being
specific to kvm, I believe this fix is pretty generic, and fits here.
Specially if we ever want to have our own irqchip in kernel too.

The problem happens after the fork system call, and although it is not
100 % reproduceable, happens pretty often. After fork, the memory where
the apic is mapped is present in both processes. It ends up confusing
the vcpus somewhere in the irq <-> ack path, and qemu hangs, with no
irqs being delivered at all from that point on.

Making sure the vcpus are stopped before forking makes the problem go
away. Besides, this is a pretty unfrequent operation, which already hangs
the io-thread for a while. So it should not hurt performance.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 net/tap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index 0147dab..f34dd9c 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -330,6 +330,9 @@ static int launch_script(const char *setup_script, const char *ifname, int fd)
     sigaddset(&mask, SIGCHLD);
     sigprocmask(SIG_BLOCK, &mask, &oldmask);
 
+    /* make sure no cpus are running, so the apic does not
+     * get confused */
+    vm_stop(0);
     /* try to launch network script */
     pid = fork();
     if (pid == 0) {
@@ -350,6 +353,7 @@ static int launch_script(const char *setup_script, const char *ifname, int fd)
         execv(setup_script, args);
         _exit(1);
     } else if (pid > 0) {
+        vm_start();
         while (waitpid(pid, &status, 0) != pid) {
             /* loop */
         }
-- 
1.7.0.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-06-22 12:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-14 19:27 [Qemu-devel] [PATCH] stop cpus before forking Glauber Costa
2010-06-14 19:33 ` Anthony Liguori
2010-06-14 19:42   ` Glauber Costa
2010-06-14 19:58     ` Anthony Liguori
2010-06-14 20:05       ` Glauber Costa
2010-06-16 16:57       ` Glauber Costa
2010-06-15  6:14     ` Daniel P. Berrange
2010-06-15  7:36       ` Avi Kivity
2010-06-15  7:35     ` Avi Kivity
2010-06-15  7:33   ` Avi Kivity
2010-06-16 16:58     ` Glauber Costa
2010-06-22 12:18       ` Avi Kivity

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).