aboutsummaryrefslogtreecommitdiff
path: root/softmmu/memory.c
diff options
context:
space:
mode:
authorAlexander Graf <graf@amazon.com>2023-04-03 22:14:21 +0000
committerDavid Hildenbrand <david@redhat.com>2023-05-23 16:47:03 +0200
commit4b870dc4d0c0895859d34d14ce0272a4bcbccf78 (patch)
tree8af35d1db6ba0cd63419627870a0a75aec9bf150 /softmmu/memory.c
parent886c0453cbf10eebd42a9ccf89c3e46eb389c357 (diff)
downloadqemu-4b870dc4d0c0895859d34d14ce0272a4bcbccf78.zip
qemu-4b870dc4d0c0895859d34d14ce0272a4bcbccf78.tar.gz
qemu-4b870dc4d0c0895859d34d14ce0272a4bcbccf78.tar.bz2
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 <graf@amazon.com> Message-Id: <20230403221421.60877-1-graf@amazon.com> Acked-by: Markus Armbruster <armbru@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com>
Diffstat (limited to 'softmmu/memory.c')
-rw-r--r--softmmu/memory.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 9ee4131..7d9494c 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1619,6 +1619,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)
{
@@ -1630,7 +1631,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
mr->destructor = memory_region_destructor_ram;
mr->align = align;
mr->ram_block = qemu_ram_alloc_from_file(size, mr, ram_flags, path,
- readonly, &err);
+ offset, readonly, &err);
if (err) {
mr->size = int128_zero();
object_unparent(OBJECT(mr));