]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Add kvm__arch_delete_ram()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 27 Dec 2011 07:36:41 +0000 (15:36 +0800)
committerPekka Enberg <penberg@kernel.org>
Tue, 3 Jan 2012 17:07:01 +0000 (19:07 +0200)
unmap all the memory maped memory for guest ram.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/kvm.h
tools/kvm/kvm.c
tools/kvm/powerpc/kvm.c
tools/kvm/x86/kvm.c

index d8ed73139256f5f48e3eaaae1354b25e4e9a4b01..d48f2e2a724f03ce171979dca109fb0838f60850 100644 (file)
@@ -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);
index cb4e5a0d7121d8d3d6857ea65052259f05ffa060..a45f041daef13b06ce687c6a759cd57bdc0efb9a 100644 (file)
@@ -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);
index 1955ad91ec06868c0285838683d6b2b6a2ee3f75..627a66a5661bdef462ef6fa6267b95b9088500c7 100644 (file)
@@ -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);
index 54c590a3fa83e61813ce61d7b856a486e63c210b..286f106c45dca6db4fcdd2e511a142fa62eaf59e 100644 (file)
@@ -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;