Commit-ID: c9173e4e2dd6dfb348d70c2df0346b959897f9c4 Gitweb: http://git.kernel.org/tip/c9173e4e2dd6dfb348d70c2df0346b959897f9c4 Author: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> AuthorDate: Tue, 27 Dec 2011 15:36:41 +0800 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Tue, 3 Jan 2012 19:07:01 +0200 kvm tools: Add kvm__arch_delete_ram() unmap all the memory maped memory for guest ram. Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/kvm.c | 2 +- tools/kvm/powerpc/kvm.c | 5 +++++ tools/kvm/x86/kvm.c | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletions(-) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index d8ed731..d48f2e2 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -61,6 +61,7 @@ void kvm__remove_socket(const char *name); void kvm__arch_set_cmdline(char *cmdline, bool video); void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size); +void kvm__arch_delete_ram(struct kvm *kvm); int kvm__arch_setup_firmware(struct kvm *kvm); bool kvm__arch_cpu_supports_vm(void); void kvm__arch_periodic_poll(struct kvm *kvm); diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index cb4e5a0..a45f041 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -246,7 +246,7 @@ void kvm__delete(struct kvm *kvm) { kvm__stop_timer(kvm); - munmap(kvm->ram_start, kvm->ram_size); + kvm__arch_delete_ram(kvm); kvm_ipc__stop(); kvm__remove_socket(kvm->name); free(kvm); diff --git a/tools/kvm/powerpc/kvm.c b/tools/kvm/powerpc/kvm.c index 1955ad9..627a66a 100644 --- a/tools/kvm/powerpc/kvm.c +++ b/tools/kvm/powerpc/kvm.c @@ -102,6 +102,11 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) "which is not yet supported."); } +void kvm__arch_delete_ram(struct kvm *kvm) +{ + munmap(kvm->ram_start, kvm->ram_size); +} + void kvm__irq_line(struct kvm *kvm, int irq, int level) { fprintf(stderr, "irq_line(%d, %d)\n", irq, level); diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c index 54c590a..286f106 100644 --- a/tools/kvm/x86/kvm.c +++ b/tools/kvm/x86/kvm.c @@ -178,6 +178,14 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) die_perror("KVM_CREATE_IRQCHIP ioctl"); } +void kvm__arch_delete_ram(struct kvm *kvm) +{ + if (kvm->ram_size < KVM_32BIT_GAP_START) + munmap(kvm->ram_start, kvm->ram_size); + else + munmap(kvm->ram_start, kvm->ram_size + KVM_32BIT_GAP_SIZE); +} + void kvm__irq_line(struct kvm *kvm, int irq, int level) { struct kvm_irq_level irq_level; -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html