]> git.proxmox.com Git - mirror_qemu.git/commitdiff
osdep, kvm: rename low-level RAM allocation functions
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 13 May 2013 14:19:55 +0000 (16:19 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 14 May 2013 13:53:31 +0000 (08:53 -0500)
This is preparatory to the introduction of a separate freeing API.

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-2-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
HACKING
exec.c
include/qemu/osdep.h
include/sysemu/kvm.h
kvm-all.c
target-s390x/kvm.c
trace-events
util/oslib-posix.c
util/oslib-win32.c

diff --git a/HACKING b/HACKING
index 6654d332493af1c647a9de26d9014195d4f6c0f8..e73ac79fe95c8e187226059b3215413ceac54d79 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -78,16 +78,15 @@ avoided.
 Use of the malloc/free/realloc/calloc/valloc/memalign/posix_memalign
 APIs is not allowed in the QEMU codebase. Instead of these routines,
 use the GLib memory allocation routines g_malloc/g_malloc0/g_new/
-g_new0/g_realloc/g_free or QEMU's qemu_vmalloc/qemu_memalign/qemu_vfree
+g_new0/g_realloc/g_free or QEMU's qemu_memalign/qemu_blockalign/qemu_vfree
 APIs.
 
 Please note that g_malloc will exit on allocation failure, so there
 is no need to test for failure (as you would have to with malloc).
 Calling g_malloc with a zero size is valid and will return NULL.
 
-Memory allocated by qemu_vmalloc or qemu_memalign must be freed with
-qemu_vfree, since breaking this will cause problems on Win32 and user
-emulators.
+Memory allocated by qemu_memalign or qemu_blockalign must be freed with
+qemu_vfree, since breaking this will cause problems on Win32.
 
 4. String manipulation
 
diff --git a/exec.c b/exec.c
index 19725dbc05e0a72767c95239337d1ed800bdf82a..49344577ea54e4d274fda16cb7dfdc805bdc2e00 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1062,7 +1062,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
 #if defined (__linux__) && !defined(TARGET_S390X)
             new_block->host = file_ram_alloc(new_block, size, mem_path);
             if (!new_block->host) {
-                new_block->host = qemu_vmalloc(size);
+                new_block->host = qemu_anon_ram_alloc(size);
                 memory_try_enable_merging(new_block->host, size);
             }
 #else
@@ -1074,9 +1074,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
                 xen_ram_alloc(new_block->offset, size, mr);
             } else if (kvm_enabled()) {
                 /* some s390/kvm configurations have special constraints */
-                new_block->host = kvm_vmalloc(size);
+                new_block->host = kvm_ram_alloc(size);
             } else {
-                new_block->host = qemu_vmalloc(size);
+                new_block->host = qemu_anon_ram_alloc(size);
             }
             memory_try_enable_merging(new_block->host, size);
         }
index 3bcd4ab7cdde22e2c5dcd0526671f27e3698465b..06c358846e77e2d538461a612f59360e3ac5e2c7 100644 (file)
@@ -96,7 +96,7 @@ typedef signed int              int_fast16_t;
 
 int qemu_daemon(int nochdir, int noclose);
 void *qemu_memalign(size_t alignment, size_t size);
-void *qemu_vmalloc(size_t size);
+void *qemu_anon_ram_alloc(size_t size);
 void qemu_vfree(void *ptr);
 
 #define QEMU_MADV_INVALID -1
index 9735c1dee651f2b6489b79c88de3d2ddb3b72c8b..08284ef7707d8ca9db977d2d04b82c269a5980b3 100644 (file)
@@ -142,8 +142,8 @@ int kvm_init_vcpu(CPUState *cpu);
 int kvm_cpu_exec(CPUArchState *env);
 
 #if !defined(CONFIG_USER_ONLY)
-void *kvm_vmalloc(ram_addr_t size);
-void *kvm_arch_vmalloc(ram_addr_t size);
+void *kvm_ram_alloc(ram_addr_t size);
+void *kvm_arch_ram_alloc(ram_addr_t size);
 #endif
 
 void kvm_setup_guest_memory(void *start, size_t size);
index 3a316023593a4c3d46fc4806dec6ecc6d44b8c8d..8222729773f2800f451b21714d77537d63d47ba2 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1790,17 +1790,17 @@ int kvm_has_intx_set_mask(void)
     return kvm_state->intx_set_mask;
 }
 
-void *kvm_vmalloc(ram_addr_t size)
+void *kvm_ram_alloc(ram_addr_t size)
 {
 #ifdef TARGET_S390X
     void *mem;
 
-    mem = kvm_arch_vmalloc(size);
+    mem = kvm_arch_ram_alloc(size);
     if (mem) {
         return mem;
     }
 #endif
-    return qemu_vmalloc(size);
+    return qemu_anon_ram_alloc(size);
 }
 
 void kvm_setup_guest_memory(void *start, size_t size)
index a585392b93e4d78c8d2bd044047ad0ae6238794f..862fb12c84dfd68ca81f23302a4f40677cd00ef5 100644 (file)
@@ -332,7 +332,7 @@ static void *legacy_s390_alloc(ram_addr_t size)
     return mem;
 }
 
-void *kvm_arch_vmalloc(ram_addr_t size)
+void *kvm_arch_ram_alloc(ram_addr_t size)
 {
     /* Can we use the standard allocation ? */
     if (kvm_check_extension(kvm_state, KVM_CAP_S390_GMAP) &&
index 4413beb99e66b223ede84494cd2d0ec56b5bc750..f1a8c3a2a14497a9eca571472bbc9a506f1f80b7 100644 (file)
@@ -32,7 +32,7 @@ g_free(void *ptr) "ptr %p"
 
 # osdep.c
 qemu_memalign(size_t alignment, size_t size, void *ptr) "alignment %zu size %zu ptr %p"
-qemu_vmalloc(size_t size, void *ptr) "size %zu ptr %p"
+qemu_anon_ram_alloc(size_t size, void *ptr) "size %zu ptr %p"
 qemu_vfree(void *ptr) "ptr %p"
 
 # hw/virtio.c
index 3efc76320a9195cb58eb116d1638e3c6e73f99b1..6acbbef971e540164fe9b21cb19c0ba861375fc1 100644 (file)
@@ -101,7 +101,7 @@ void *qemu_memalign(size_t alignment, size_t size)
 }
 
 /* alloc shared memory pages */
-void *qemu_vmalloc(size_t size)
+void *qemu_anon_ram_alloc(size_t size)
 {
     size_t align = QEMU_VMALLOC_ALIGN;
     size_t total = size + align - getpagesize();
@@ -125,7 +125,7 @@ void *qemu_vmalloc(size_t size)
         munmap(ptr + size, total - size);
     }
 
-    trace_qemu_vmalloc(size, ptr);
+    trace_qemu_anon_ram_alloc(size, ptr);
     return ptr;
 }
 
index dcfa0c2918ab303abd594ba20befa6f0b5dcb345..5b1fc20cc630d85e60dc12fce41022a034e6a537 100644 (file)
@@ -53,7 +53,7 @@ void *qemu_memalign(size_t alignment, size_t size)
     return ptr;
 }
 
-void *qemu_vmalloc(size_t size)
+void *qemu_anon_ram_alloc(size_t size)
 {
     void *ptr;
 
@@ -64,7 +64,7 @@ void *qemu_vmalloc(size_t size)
         abort();
     }
     ptr = qemu_oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE));
-    trace_qemu_vmalloc(size, ptr);
+    trace_qemu_anon_ram_alloc(size, ptr);
     return ptr;
 }