From 4b870dc4d0c0895859d34d14ce0272a4bcbccf78 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 3 Apr 2023 22:14:21 +0000 Subject: hostmem-file: add offset option Add an option for hostmem-file to start the memory object at an offset into the target file. This is useful if multiple memory objects reside inside the same target file, such as a device node. In particular, it's useful to map guest memory directly into /dev/mem for experimentation. To make this work consistently, also fix up all places in QEMU that expect fd offsets to be 0. Signed-off-by: Alexander Graf Message-Id: <20230403221421.60877-1-graf@amazon.com> Acked-by: Markus Armbruster Acked-by: Peter Xu Reviewed-by: David Hildenbrand Signed-off-by: David Hildenbrand --- include/exec/memory.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/exec/memory.h') diff --git a/include/exec/memory.h b/include/exec/memory.h index 6f24a3dd46..c3661b2276 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1326,6 +1326,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr, * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM, * RAM_NORESERVE, * @path: the path in which to allocate the RAM. + * @offset: offset within the file referenced by path * @readonly: true to open @path for reading, false for read/write. * @errp: pointer to Error*, to store an error if it happens. * @@ -1339,6 +1340,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, uint64_t align, uint32_t ram_flags, const char *path, + ram_addr_t offset, bool readonly, Error **errp); -- cgit 1.4.1