Patchwork [05/10] kvm_init_vcpu requires global lock held

login
register
mail settings
Submitter Marcelo Tosatti
Date April 26, 2010, 5:59 p.m.
Message ID <6164e6d6e86e8f3f0b5ff7ae08b677026cb291c3.1272304746.git.mtosatti@redhat.com>
Download mbox | patch
Permalink /patch/50991/
State New
Headers show

Comments

Marcelo Tosatti - April 26, 2010, 5:59 p.m.
Since it accesses data protected by the lock.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 cpus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index 8450ee4..2bf87d2 100644
--- a/cpus.c
+++ b/cpus.c
@@ -401,6 +401,7 @@  static void *kvm_cpu_thread_fn(void *arg)
 {
     CPUState *env = arg;
 
+    qemu_mutex_lock(&qemu_global_mutex);
     qemu_thread_self(env->thread);
     if (kvm_enabled())
         kvm_init_vcpu(env);
@@ -408,7 +409,6 @@  static void *kvm_cpu_thread_fn(void *arg)
     kvm_block_io_signals(env);
 
     /* signal CPU creation */
-    qemu_mutex_lock(&qemu_global_mutex);
     env->created = 1;
     qemu_cond_signal(&qemu_cpu_cond);