qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC v3 47/56] cpu: call .cpu_has_work with the CPU lock he


From: Emilio G. Cota
Subject: [Qemu-devel] [RFC v3 47/56] cpu: call .cpu_has_work with the CPU lock held
Date: Thu, 18 Oct 2018 21:06:16 -0400

Signed-off-by: Emilio G. Cota <address@hidden>
---
 include/qom/cpu.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index cd66b8828a..ca7d92c360 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -784,9 +784,16 @@ const char *parse_cpu_model(const char *cpu_model);
 static inline bool cpu_has_work(CPUState *cpu)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
+    bool ret;
 
     g_assert(cc->has_work);
-    return cc->has_work(cpu);
+    if (cpu_mutex_locked(cpu)) {
+        return cc->has_work(cpu);
+    }
+    cpu_mutex_lock(cpu);
+    ret = cc->has_work(cpu);
+    cpu_mutex_unlock(cpu);
+    return ret;
 }
 
 /**
-- 
2.17.1




reply via email to

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