qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, akong@redhat.com
Subject: [Qemu-devel] [PATCH for-1.5 1/2] osdep, kvm: rename low-level RAM allocation functions
Date: Mon, 13 May 2013 16:19:55 +0200	[thread overview]
Message-ID: <1368454796-14989-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1368454796-14989-1-git-send-email-pbonzini@redhat.com>

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>
---
 HACKING              | 7 +++----
 exec.c               | 6 +++---
 include/qemu/osdep.h | 2 +-
 include/sysemu/kvm.h | 4 ++--
 kvm-all.c            | 6 +++---
 target-s390x/kvm.c   | 2 +-
 trace-events         | 2 +-
 util/oslib-posix.c   | 4 ++--
 util/oslib-win32.c   | 4 ++--
 9 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/HACKING b/HACKING
index 6654d33..e73ac79 100644
--- 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 19725db..b7e7494 100644
--- 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);
         }
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 42545bc..ae71042 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -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
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 9735c1d..95c0dc9 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -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);
diff --git a/kvm-all.c b/kvm-all.c
index 3a31602..92709a2 100644
--- 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)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index a585392..7d49d73 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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) &&
diff --git a/trace-events b/trace-events
index 17d75ab..acf0f5c 100644
--- a/trace-events
+++ b/trace-events
@@ -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
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 3efc763..e7e9c01 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -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;
 }
 
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index dcfa0c2..e83c22b 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -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;
 }
 
-- 
1.8.2.1

  reply	other threads:[~2013-05-13 14:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 14:19 [Qemu-devel] [PATCH for-1.5 0/2] Fix hot-unplug of devices with ROM or RAM Paolo Bonzini
2013-05-13 14:19 ` Paolo Bonzini [this message]
2013-05-13 14:19 ` [Qemu-devel] [PATCH for-1.5 2/2] osdep: introduce qemu_anon_ram_free to free qemu_anon_ram_alloc-ed memory Paolo Bonzini
2013-05-13 14:26   ` Peter Maydell
2013-05-13 14:45     ` Paolo Bonzini
2013-05-15 14:36   ` Markus Armbruster
2013-05-15 14:44     ` Paolo Bonzini
2013-05-18 11:51       ` Stefan Weil
2013-05-14  2:13 ` [Qemu-devel] [PATCH for-1.5 0/2] Fix hot-unplug of devices with ROM or RAM Amos Kong
2013-05-14 16:11 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368454796-14989-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).