[patch 6/6] qemu-kvm: use reset handler for vcpus

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

 



Hook into the reset handlers instead of using custom code in
qemu_kvm_system_reset.

Also move kvm_arch_init_vcpu to kvm_create_vcpu.

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

Index: qemu-kvm-cleanups/qemu-kvm.c
===================================================================
--- qemu-kvm-cleanups.orig/qemu-kvm.c
+++ qemu-kvm-cleanups/qemu-kvm.c
@@ -439,6 +439,13 @@ void kvm_disable_pit_creation(kvm_contex
     kvm->no_pit_creation = 1;
 }
 
+static void kvm_reset_vcpu(void *opaque)
+{
+    CPUState *env = opaque;
+
+    kvm_arch_cpu_reset(env);
+}
+
 static void kvm_create_vcpu(CPUState *env, int id)
 {
     long mmap_size;
@@ -473,6 +480,11 @@ static void kvm_create_vcpu(CPUState *en
                s->coalesced_mmio * PAGE_SIZE;
 #endif
 
+    r = kvm_arch_init_vcpu(env);
+    if (r == 0) {
+        qemu_register_reset(kvm_reset_vcpu, env);
+    }
+
     return;
   err_fd:
     close(env->kvm_fd);
@@ -1777,17 +1789,10 @@ static void setup_kernel_sigmask(CPUStat
 
 static void qemu_kvm_system_reset(void)
 {
-    CPUState *penv = first_cpu;
-
     pause_all_threads();
 
     qemu_system_reset();
 
-    while (penv) {
-        kvm_arch_cpu_reset(penv);
-        penv = (CPUState *) penv->next_cpu;
-    }
-
     resume_all_threads();
 }
 
@@ -1829,7 +1834,6 @@ static void *ap_main_loop(void *_env)
     env->thread_id = kvm_get_thread_id();
     sigfillset(&signals);
     sigprocmask(SIG_BLOCK, &signals, NULL);
-    kvm_create_vcpu(env, env->cpu_index);
 
 #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
     /* do ioperm for io ports of assigned devices */
@@ -1837,12 +1841,11 @@ static void *ap_main_loop(void *_env)
         on_vcpu(env, kvm_arch_do_ioperm, data);
 #endif
 
-    setup_kernel_sigmask(env);
-
     pthread_mutex_lock(&qemu_mutex);
     cpu_single_env = env;
 
-    kvm_arch_init_vcpu(env);
+    kvm_create_vcpu(env, env->cpu_index);
+    setup_kernel_sigmask(env);
 
     /* signal VCPU creation */
     current_env->created = 1;


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux