From a35ba7be4b696d4c7b47318fd2022e6c3eca0a63 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 10 Jun 2014 19:15:23 +0800 Subject: hostmem: allow preallocation of any memory region And allow preallocation of file-based memory even without -mem-prealloc. Some care is necessary because -mem-prealloc does not allow disabling preallocation for hostmem-file. Signed-off-by: Paolo Bonzini Signed-off-by: Hu Tao Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memory.h | 10 ++++++++++ include/exec/ram_addr.h | 1 + 2 files changed, 11 insertions(+) (limited to 'include/exec') diff --git a/include/exec/memory.h b/include/exec/memory.h index 4c7bacf959..1cf5981b2e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -533,6 +533,16 @@ bool memory_region_is_logging(MemoryRegion *mr); */ bool memory_region_is_rom(MemoryRegion *mr); +/** + * memory_region_get_fd: Get a file descriptor backing a RAM memory region. + * + * Returns a file descriptor backing a file-based RAM memory region, + * or -1 if the region is not a file-based RAM memory region. + * + * @mr: the RAM or alias memory region being queried. + */ +int memory_region_get_fd(MemoryRegion *mr); + /** * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. * diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index deafcebac0..fcc7ef0180 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -27,6 +27,7 @@ ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr); ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); +int qemu_get_ram_fd(ram_addr_t addr); void *qemu_get_ram_ptr(ram_addr_t addr); void qemu_ram_free(ram_addr_t addr); void qemu_ram_free_from_ptr(ram_addr_t addr); -- cgit v1.2.3-55-g7522