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 --- hw/virtio/vhost-user.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/virtio/vhost-user.c') diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e3ec872..74a2a28 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -473,6 +473,7 @@ static MemoryRegion *vhost_user_get_mr_data(uint64_t addr, ram_addr_t *offset, assert((uintptr_t)addr == addr); mr = memory_region_from_host((void *)(uintptr_t)addr, offset); *fd = memory_region_get_fd(mr); + *offset += mr->ram_block->fd_offset; return mr; } -- cgit v1.1