summary refs log tree commit diff stats
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-05-13 16:19:56 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-05-14 08:53:31 -0500
commite7a09b92b70786f9e8c5fbf787e0248c6ebbe707 (patch)
tree4a24722a71dd1194a7f7cb455ef48e504925d34d /util/oslib-posix.c
parent6eebf958abf3f3f701116d4524ef88bb9fd6e341 (diff)
downloadfocaccia-qemu-e7a09b92b70786f9e8c5fbf787e0248c6ebbe707.tar.gz
focaccia-qemu-e7a09b92b70786f9e8c5fbf787e0248c6ebbe707.zip
osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory
We switched from qemu_memalign to mmap() but then we don't modify
qemu_vfree() to do a munmap() over free().  Which we cannot do
because qemu_vfree() frees memory allocated by qemu_{mem,block}align.

Introduce a new function that does the munmap(), luckily the size is
available in the RAMBlock.

Reported-by: Amos Kong <akong@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Amos Kong <akong@redhat.com>
Message-id: 1368454796-14989-3-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 6acbbef971..631a1dea33 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -135,6 +135,14 @@ void qemu_vfree(void *ptr)
     free(ptr);
 }
 
+void qemu_anon_ram_free(void *ptr, size_t size)
+{
+    trace_qemu_anon_ram_free(ptr, size);
+    if (ptr) {
+        munmap(ptr, size);
+    }
+}
+
 void qemu_set_block(int fd)
 {
     int f;