]> git.proxmox.com Git - mirror_qemu.git/commitdiff
do proper cpu_self check
authorGlauber Costa <glommer@mothafucka.localdomain>
Mon, 28 Sep 2009 18:27:44 +0000 (15:27 -0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 5 Oct 2009 14:32:44 +0000 (09:32 -0500)
Currently, our check for qemu_cpu_self only checks if there is a cpu
currently in execution (represented by cpu_single_env being set). While
this might be okay for tcg, it is certainly not okay for kvm, since multiple
cpus might be executing.

Instead, I propose we use pthread primitives to test if the caller thread is
the same as env->thread.

For tcg, it will have the same semantics as before, since all CPUStates will
point to the same thread, and we'll only have one in execution at a time.

Signed-off-by: Glauber Costa <glommer@mothafucka.localdomain>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index 4d9db0145cc9aebd717f1ce29562f70f9257bf8a..19e11b2f704f3837ef678989a734e431e06dbebe 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3591,9 +3591,14 @@ void qemu_cpu_kick(void *_env)
         qemu_thread_signal(env->thread, SIGUSR1);
 }
 
-int qemu_cpu_self(void *env)
+int qemu_cpu_self(void *_env)
 {
-    return (cpu_single_env != NULL);
+    CPUState *env = _env;
+    QemuThread this;
+    qemu_thread_self(&this);
+    return qemu_thread_equal(&this, env->thread);
 }
 
 static void cpu_signal(int sig)