diff mbox

qemu-kvm initialize vcpu state after machine initialization

Message ID 20091214203637.GA7120@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti Dec. 14, 2009, 8:36 p.m. UTC
None
diff mbox

Patch

diff --git a/hw/apic.c b/hw/apic.c
index ae805dc..627ff98 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -1131,11 +1131,6 @@  int apic_init(CPUState *env)
     vmstate_register(s->idx, &vmstate_apic, s);
     qemu_register_reset(apic_reset, s);
 
-    /* apic_reset must be called before the vcpu threads are initialized and load
-     * registers, in qemu-kvm.
-     */
-    apic_reset(s);
-
     local_apics[s->idx] = s;
     return 0;
 }
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 44e8b75..ef8c288 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1918,11 +1918,6 @@  static void *ap_main_loop(void *_env)
     setup_kernel_sigmask(env);
 
     pthread_mutex_lock(&qemu_mutex);
-    cpu_single_env = env;
-
-    kvm_arch_init_vcpu(env);
-
-    kvm_arch_load_regs(env);
 
     /* signal VCPU creation */
     current_env->created = 1;
@@ -1934,6 +1929,8 @@  static void *ap_main_loop(void *_env)
 
     /* re-initialize cpu_single_env after re-acquiring qemu_mutex */
     cpu_single_env = env;
+    kvm_arch_init_vcpu(env);
+    kvm_arch_load_regs(env);
 
     kvm_main_loop_cpu(env);
     return NULL;