summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/kvm-all.c b/kvm-all.c
index d843338f3..017296bc0 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -143,6 +143,15 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
}
+static void kvm_reset_vcpu(void *opaque)
+{
+ CPUState *env = opaque;
+
+ if (kvm_arch_put_registers(env)) {
+ fprintf(stderr, "Fatal: kvm vcpu reset failed\n");
+ abort();
+ }
+}
int kvm_init_vcpu(CPUState *env)
{
@@ -176,7 +185,10 @@ int kvm_init_vcpu(CPUState *env)
}
ret = kvm_arch_init_vcpu(env);
-
+ if (ret == 0) {
+ qemu_register_reset(kvm_reset_vcpu, 0, env);
+ ret = kvm_arch_put_registers(env);
+ }
err:
return ret;
}
@@ -201,21 +213,6 @@ int kvm_get_mp_state(CPUState *env)
return 0;
}
-int kvm_sync_vcpus(void)
-{
- CPUState *env;
-
- for (env = first_cpu; env != NULL; env = env->next_cpu) {
- int ret;
-
- ret = kvm_arch_put_registers(env);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
/*
* dirty pages logging control
*/
@@ -397,11 +394,6 @@ int kvm_check_extension(KVMState *s, unsigned int extension)
return ret;
}
-static void kvm_reset_vcpus(void *opaque)
-{
- kvm_sync_vcpus();
-}
-
int kvm_init(int smp_cpus)
{
static const char upgrade_note[] =
@@ -492,8 +484,6 @@ int kvm_init(int smp_cpus)
if (ret < 0)
goto err;
- qemu_register_reset(kvm_reset_vcpus, INT_MAX, NULL);
-
kvm_state = s;
return 0;