mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
memory, exec: switch file ram allocation functions to 'flags' parameters
As more flag parameters besides the existing 'share' are going to be added to following functions memory_region_init_ram_from_file qemu_ram_alloc_from_fd qemu_ram_alloc_from_file let's switch them to use the 'flags' parameters so as to ease future flag additions. The existing 'share' flag is converted to the RAM_SHARED bit in ram_flags, and other flag bits are ignored by above functions right now. Signed-off-by: Junyan He <junyan.he@intel.com> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
b0e5de9381
commit
cbfc017103
6 changed files with 41 additions and 14 deletions
|
@ -640,6 +640,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
|
|||
void *host),
|
||||
Error **errp);
|
||||
#ifdef __linux__
|
||||
|
||||
/**
|
||||
* memory_region_init_ram_from_file: Initialize RAM memory region with a
|
||||
* mmap-ed backend.
|
||||
|
@ -651,7 +652,9 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
|
|||
* @size: size of the region.
|
||||
* @align: alignment of the region base address; if 0, the default alignment
|
||||
* (getpagesize()) will be used.
|
||||
* @share: %true if memory must be mmaped with the MAP_SHARED flag
|
||||
* @ram_flags: Memory region features:
|
||||
* - RAM_SHARED: memory must be mmaped with the MAP_SHARED flag
|
||||
* Other bits are ignored now.
|
||||
* @path: the path in which to allocate the RAM.
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
*
|
||||
|
@ -663,7 +666,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
|
|||
const char *name,
|
||||
uint64_t size,
|
||||
uint64_t align,
|
||||
bool share,
|
||||
uint32_t ram_flags,
|
||||
const char *path,
|
||||
Error **errp);
|
||||
|
||||
|
|
|
@ -71,12 +71,33 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
|
|||
}
|
||||
|
||||
long qemu_getrampagesize(void);
|
||||
|
||||
/**
|
||||
* qemu_ram_alloc_from_file,
|
||||
* qemu_ram_alloc_from_fd: Allocate a ram block from the specified backing
|
||||
* file or device
|
||||
*
|
||||
* Parameters:
|
||||
* @size: the size in bytes of the ram block
|
||||
* @mr: the memory region where the ram block is
|
||||
* @ram_flags: specify the properties of the ram block, which can be one
|
||||
* or bit-or of following values
|
||||
* - RAM_SHARED: mmap the backing file or device with MAP_SHARED
|
||||
* Other bits are ignored.
|
||||
* @mem_path or @fd: specify the backing file or device
|
||||
* @errp: pointer to Error*, to store an error if it happens
|
||||
*
|
||||
* Return:
|
||||
* On success, return a pointer to the ram block.
|
||||
* On failure, return NULL.
|
||||
*/
|
||||
RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
|
||||
bool share, const char *mem_path,
|
||||
uint32_t ram_flags, const char *mem_path,
|
||||
Error **errp);
|
||||
RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
|
||||
bool share, int fd,
|
||||
uint32_t ram_flags, int fd,
|
||||
Error **errp);
|
||||
|
||||
RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
||||
MemoryRegion *mr, Error **errp);
|
||||
RAMBlock *qemu_ram_alloc(ram_addr_t size, bool share, MemoryRegion *mr,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue