]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
cpus: use broadcast on qemu_pause_cond
authorDr. David Alan Gilbert <dgilbert@redhat.com>
Mon, 25 Jan 2016 10:08:18 +0000 (10:08 +0000)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 17 Mar 2016 21:47:04 +0000 (16:47 -0500)
Jiri saw a hang on pause_all_vcpus called from postcopy_start,
where the cpus are all apparently stopped ('stopped' flag set)
but pause_all_vcpus is still stuck on a cond_wait on qemu_paused_cond.
We suspect this is happening if a qmp_stop is called at about the
same time as the postcopy code calls that pause_all_vcpus;
although they both should have the main lock held, Paolo spotted
the cond_wait unlocks the global lock so perhaps they both
could end up waiting at the same time?

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1453716498-27238-1-git-send-email-dgilbert@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 96bce6831bd19b61e965384427741d805c7234c3)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
cpus.c

diff --git a/cpus.c b/cpus.c
index 43676fa1f31622b002387e7da02cfbcecdc8e85a..747f14dc7fa541dcc013ec0b4df016c63cb0177d 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -986,7 +986,7 @@ static void qemu_wait_io_event_common(CPUState *cpu)
     if (cpu->stop) {
         cpu->stop = false;
         cpu->stopped = true;
-        qemu_cond_signal(&qemu_pause_cond);
+        qemu_cond_broadcast(&qemu_pause_cond);
     }
     flush_queued_work(cpu);
     cpu->thread_kicked = false;
@@ -1387,7 +1387,7 @@ void cpu_stop_current(void)
         current_cpu->stop = false;
         current_cpu->stopped = true;
         cpu_exit(current_cpu);
-        qemu_cond_signal(&qemu_pause_cond);
+        qemu_cond_broadcast(&qemu_pause_cond);
     }
 }