qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 2/5] cpu: Don't try to pause CPUs if they are already


From: Eduardo Habkost
Subject: [Qemu-devel] [RFC 2/5] cpu: Don't try to pause CPUs if they are already stopped
Date: Wed, 30 Apr 2014 17:29:30 -0300

This will make the pause_all_cpus() code not crash in case
qemu_init_vcpu() was not called yet for a CPU (so it doesn't have
cpu->thread set yet).

Signed-off-by: Eduardo Habkost <address@hidden>
---
 cpus.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cpus.c b/cpus.c
index 69b0530..ca3862b 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1070,6 +1070,14 @@ static int all_vcpus_paused(void)
     return 1;
 }
 
+static void cpu_kick_if_running(CPUState *cpu)
+{
+    if (!cpu->stopped) {
+        assert(cpu->thread);
+        qemu_cpu_kick(cpu);
+    }
+}
+
 void pause_all_vcpus(void)
 {
     CPUState *cpu;
@@ -1077,7 +1085,7 @@ void pause_all_vcpus(void)
     qemu_clock_enable(QEMU_CLOCK_VIRTUAL, false);
     CPU_FOREACH(cpu) {
         cpu->stop = true;
-        qemu_cpu_kick(cpu);
+        cpu_kick_if_running(cpu);
     }
 
     if (qemu_in_vcpu_thread()) {
@@ -1094,7 +1102,7 @@ void pause_all_vcpus(void)
     while (!all_vcpus_paused()) {
         qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
         CPU_FOREACH(cpu) {
-            qemu_cpu_kick(cpu);
+            cpu_kick_if_running(cpu);
         }
     }
 }
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]