diff options
-rw-r--r-- | kvm-all.c | 15 | ||||
-rw-r--r-- | kvm.h | 1 | ||||
-rw-r--r-- | vl.c | 11 |
3 files changed, 27 insertions, 0 deletions
@@ -141,6 +141,21 @@ err: return ret; } +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 */ @@ -31,6 +31,7 @@ struct kvm_run; int kvm_init(int smp_cpus); int kvm_init_vcpu(CPUState *env); +int kvm_sync_vcpus(void); int kvm_cpu_exec(CPUState *env); @@ -5456,6 +5456,17 @@ int main(int argc, char **argv, char **envp) machine->init(ram_size, vga_ram_size, boot_devices, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); + /* Set KVM's vcpu state to qemu's initial CPUState. */ + if (kvm_enabled()) { + int ret; + + ret = kvm_sync_vcpus(); + if (ret < 0) { + fprintf(stderr, "failed to initialize vcpus\n"); + exit(1); + } + } + /* init USB devices */ if (usb_enabled) { for(i = 0; i < usb_devices_index; i++) { |