diff options
author | Zhang Xiantao <xiantao@vtsmp-build32.los-vmm.org> | 2007-11-18 05:43:45 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:04 -0500 |
commit | d19a9cd275b0fdc793d1bb8b644b7aad0517e4bc (patch) | |
tree | 5dba36f58295f165e4fd3380742875d1867266f5 /drivers/kvm/x86.c | |
parent | a16b043cc96db4a01abb337bef4a51cebcfcbb1b (diff) |
KVM: Portability: Add two hooks to handle kvm_create and destroy vm
Add two arch hooks to handle kvm_create_vm and kvm destroy_vm. Now, just
put io_bus init and destory in common.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r-- | drivers/kvm/x86.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c index abb7beeb8f54..b7c72ac36735 100644 --- a/drivers/kvm/x86.c +++ b/drivers/kvm/x86.c | |||
@@ -2543,3 +2543,50 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) | |||
2543 | kvm_mmu_destroy(vcpu); | 2543 | kvm_mmu_destroy(vcpu); |
2544 | free_page((unsigned long)vcpu->pio_data); | 2544 | free_page((unsigned long)vcpu->pio_data); |
2545 | } | 2545 | } |
2546 | |||
2547 | struct kvm *kvm_arch_create_vm(void) | ||
2548 | { | ||
2549 | struct kvm *kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL); | ||
2550 | |||
2551 | if (!kvm) | ||
2552 | return ERR_PTR(-ENOMEM); | ||
2553 | |||
2554 | INIT_LIST_HEAD(&kvm->active_mmu_pages); | ||
2555 | |||
2556 | return kvm; | ||
2557 | } | ||
2558 | |||
2559 | static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu) | ||
2560 | { | ||
2561 | vcpu_load(vcpu); | ||
2562 | kvm_mmu_unload(vcpu); | ||
2563 | vcpu_put(vcpu); | ||
2564 | } | ||
2565 | |||
2566 | static void kvm_free_vcpus(struct kvm *kvm) | ||
2567 | { | ||
2568 | unsigned int i; | ||
2569 | |||
2570 | /* | ||
2571 | * Unpin any mmu pages first. | ||
2572 | */ | ||
2573 | for (i = 0; i < KVM_MAX_VCPUS; ++i) | ||
2574 | if (kvm->vcpus[i]) | ||
2575 | kvm_unload_vcpu_mmu(kvm->vcpus[i]); | ||
2576 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | ||
2577 | if (kvm->vcpus[i]) { | ||
2578 | kvm_arch_vcpu_free(kvm->vcpus[i]); | ||
2579 | kvm->vcpus[i] = NULL; | ||
2580 | } | ||
2581 | } | ||
2582 | |||
2583 | } | ||
2584 | |||
2585 | void kvm_arch_destroy_vm(struct kvm *kvm) | ||
2586 | { | ||
2587 | kfree(kvm->vpic); | ||
2588 | kfree(kvm->vioapic); | ||
2589 | kvm_free_vcpus(kvm); | ||
2590 | kvm_free_physmem(kvm); | ||
2591 | kfree(kvm); | ||
2592 | } | ||