]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
kvm: sync vcpu state during initialization (Hollis Blanchard)
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 15 Dec 2008 22:20:42 +0000 (22:20 +0000)
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 15 Dec 2008 22:20:42 +0000 (22:20 +0000)
Currently on x86, qemu initializes CPUState but KVM ignores it and does its
own vcpu initialization. However, PowerPC KVM needs to be able to set the
initial register state to support the -kernel and -append options.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6060 c046a42c-6fe2-441c-8c8c-71466251a162

kvm-all.c
kvm.h
vl.c

index dad80df581d5724f8e575cbbf5f5e4c48b20fe47..11034df27f60c7799bbbc47287a4dd10e74ba7d8 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -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
  */
diff --git a/kvm.h b/kvm.h
index ac464ab1bf9c4db7f9abc17bd63f5b7dde0bae8a..efce1450d598cda72d95cccc63c1237af0e0b237 100644 (file)
--- a/kvm.h
+++ b/kvm.h
@@ -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);
 
diff --git a/vl.c b/vl.c
index c3a8d8fc9a94ed9a69405967cdd4258c1fe921a0..0a021515abcfadf2f5ee0caf818374cbeafa537b 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -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++) {