summaryrefslogtreecommitdiffstats
path: root/util/mmap-alloc.c
diff options
context:
space:
mode:
authorJagannathan Raman2021-01-29 17:46:04 +0100
committerStefan Hajnoczi2021-02-09 21:53:56 +0100
commit44a4ff31c01082ffce08ec3b9a87a4fdf15919d5 (patch)
tree12d221ae0ba47bf3a853248b3b42bae208a07c6b /util/mmap-alloc.c
parentmulti-process: add configure and usage information (diff)
downloadqemu-44a4ff31c01082ffce08ec3b9a87a4fdf15919d5.tar.gz
qemu-44a4ff31c01082ffce08ec3b9a87a4fdf15919d5.tar.xz
qemu-44a4ff31c01082ffce08ec3b9a87a4fdf15919d5.zip
memory: alloc RAM from file at offset
Allow RAM MemoryRegion to be created from an offset in a file, instead of allocating at offset of 0 by default. This is needed to synchronize RAM between QEMU & remote process. Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Signed-off-by: John G Johnson <john.g.johnson@oracle.com> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 609996697ad8617e3b01df38accc5c208c24d74e.1611938319.git.jag.raman@oracle.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util/mmap-alloc.c')
-rw-r--r--util/mmap-alloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 890fda6a35..e6fa8b598b 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -87,7 +87,8 @@ void *qemu_ram_mmap(int fd,
size_t align,
bool readonly,
bool shared,
- bool is_pmem)
+ bool is_pmem,
+ off_t map_offset)
{
int prot;
int flags;
@@ -150,7 +151,8 @@ void *qemu_ram_mmap(int fd,
prot = PROT_READ | (readonly ? 0 : PROT_WRITE);
- ptr = mmap(guardptr + offset, size, prot, flags | map_sync_flags, fd, 0);
+ ptr = mmap(guardptr + offset, size, prot,
+ flags | map_sync_flags, fd, map_offset);
if (ptr == MAP_FAILED && map_sync_flags) {
if (errno == ENOTSUP) {
@@ -174,7 +176,7 @@ void *qemu_ram_mmap(int fd,
* if map failed with MAP_SHARED_VALIDATE | MAP_SYNC,
* we will remove these flags to handle compatibility.
*/
- ptr = mmap(guardptr + offset, size, prot, flags, fd, 0);
+ ptr = mmap(guardptr + offset, size, prot, flags, fd, map_offset);
}
if (ptr == MAP_FAILED) {