aboutsummaryrefslogtreecommitdiff
path: root/include/exec
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 /include/exec
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 'include/exec')
-rw-r--r--include/exec/memory.h2
-rw-r--r--include/exec/ram_addr.h3
-rw-r--r--include/exec/ramblock.h1
3 files changed, 5 insertions, 1 deletions
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 6f24a3d..c3661b2 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);
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index f4fb6a2..90a8269 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -110,6 +110,7 @@ long qemu_maxrampagesize(void);
* @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
* RAM_NORESERVE.
* @mem_path or @fd: specify the backing file or device
+ * @offset: Offset into target file
* @readonly: true to open @path for reading, false for read/write.
* @errp: pointer to Error*, to store an error if it happens
*
@@ -119,7 +120,7 @@ long qemu_maxrampagesize(void);
*/
RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
uint32_t ram_flags, const char *mem_path,
- bool readonly, Error **errp);
+ off_t offset, bool readonly, Error **errp);
RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
uint32_t ram_flags, int fd, off_t offset,
bool readonly, Error **errp);
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h
index adc03df..69c6a53 100644
--- a/include/exec/ramblock.h
+++ b/include/exec/ramblock.h
@@ -40,6 +40,7 @@ struct RAMBlock {
QLIST_ENTRY(RAMBlock) next;
QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
int fd;
+ uint64_t fd_offset;
size_t page_size;
/* dirty bitmap used during migration */
unsigned long *bmap;