Commit 6eebf958 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Anthony Liguori
Browse files

osdep, kvm: rename low-level RAM allocation functions



This is preparatory to the introduction of a separate freeing API.

Reported-by: default avatarAmos Kong <akong@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarAmos Kong <akong@redhat.com>
Message-id: 1368454796-14989-2-git-send-email-pbonzini@redhat.com
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent d34dc45d
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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

+3 −3
Original line number Diff line number Diff line
@@ -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);
        }
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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);
+3 −3
Original line number Diff line number Diff line
@@ -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)
Loading