Commit f5d6f51ba66aad038f1bc4436582761015838438
1 parent
8d6c92b6
kvm: sync vcpu state during initialization (Hollis Blanchard)
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
Showing
3 changed files
with
27 additions
and
0 deletions
kvm-all.c
... | ... | @@ -141,6 +141,21 @@ err: |
141 | 141 | return ret; |
142 | 142 | } |
143 | 143 | |
144 | +int kvm_sync_vcpus(void) | |
145 | +{ | |
146 | + CPUState *env; | |
147 | + | |
148 | + for (env = first_cpu; env != NULL; env = env->next_cpu) { | |
149 | + int ret; | |
150 | + | |
151 | + ret = kvm_arch_put_registers(env); | |
152 | + if (ret) | |
153 | + return ret; | |
154 | + } | |
155 | + | |
156 | + return 0; | |
157 | +} | |
158 | + | |
144 | 159 | /* |
145 | 160 | * dirty pages logging control |
146 | 161 | */ | ... | ... |
kvm.h
vl.c
... | ... | @@ -5456,6 +5456,17 @@ int main(int argc, char **argv, char **envp) |
5456 | 5456 | machine->init(ram_size, vga_ram_size, boot_devices, ds, |
5457 | 5457 | kernel_filename, kernel_cmdline, initrd_filename, cpu_model); |
5458 | 5458 | |
5459 | + /* Set KVM's vcpu state to qemu's initial CPUState. */ | |
5460 | + if (kvm_enabled()) { | |
5461 | + int ret; | |
5462 | + | |
5463 | + ret = kvm_sync_vcpus(); | |
5464 | + if (ret < 0) { | |
5465 | + fprintf(stderr, "failed to initialize vcpus\n"); | |
5466 | + exit(1); | |
5467 | + } | |
5468 | + } | |
5469 | + | |
5459 | 5470 | /* init USB devices */ |
5460 | 5471 | if (usb_enabled) { |
5461 | 5472 | for(i = 0; i < usb_devices_index; i++) { | ... | ... |