[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/41] Add memory_region_init_ram_from_fd()
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 04/41] Add memory_region_init_ram_from_fd() |
Date: |
Thu, 15 Jun 2017 12:52:24 +0200 |
From: Marc-André Lureau <address@hidden>
Add a new function to initialize a RAM memory region with a file
descriptor to be mmap-ed.
Signed-off-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/exec/memory.h | 20 ++++++++++++++++++++
memory.c | 16 ++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 80e605a..51a54c9 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -456,6 +456,26 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
bool share,
const char *path,
Error **errp);
+
+/**
+ * memory_region_init_ram_from_fd: Initialize RAM memory region with a
+ * mmap-ed backend.
+ *
+ * @mr: the #MemoryRegion to be initialized.
+ * @owner: the object that tracks the region's reference count
+ * @name: the name of the region.
+ * @size: size of the region.
+ * @share: %true if memory must be mmaped with the MAP_SHARED flag
+ * @fd: the fd to mmap.
+ * @errp: pointer to Error*, to store an error if it happens.
+ */
+void memory_region_init_ram_from_fd(MemoryRegion *mr,
+ struct Object *owner,
+ const char *name,
+ uint64_t size,
+ bool share,
+ int fd,
+ Error **errp);
#endif
/**
diff --git a/memory.c b/memory.c
index 0ddc4cc..b2ace20 100644
--- a/memory.c
+++ b/memory.c
@@ -1397,6 +1397,22 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
mr->ram_block = qemu_ram_alloc_from_file(size, mr, share, path, errp);
mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
+
+void memory_region_init_ram_from_fd(MemoryRegion *mr,
+ struct Object *owner,
+ const char *name,
+ uint64_t size,
+ bool share,
+ int fd,
+ Error **errp)
+{
+ memory_region_init(mr, owner, name, size);
+ mr->ram = true;
+ mr->terminates = true;
+ mr->destructor = memory_region_destructor_ram;
+ mr->ram_block = qemu_ram_alloc_from_fd(size, mr, share, fd, errp);
+ mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+}
#endif
void memory_region_init_ram_ptr(MemoryRegion *mr,
--
1.8.3.1
- [Qemu-devel] [PULL 00/41] Misc patches for 2017-06-15, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 01/41] exec: check kvm mmu notifiers earlier, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 03/41] exec: split qemu_ram_alloc_from_file(), Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 02/41] exec: split file_ram_alloc(), Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 04/41] Add memory_region_init_ram_from_fd(),
Paolo Bonzini <=
- [Qemu-devel] [PULL 08/41] megasas: do not read sense length more than once from frame, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 06/41] memory: remove memory_region_set_fd, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 12/41] megasas: do not read SCSI req parameters more than once from frame, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 16/41] kvm-all: make async_safe_run_on_cpu safe on kvm too, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 09/41] megasas: do not read iovec count more than once from frame, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 14/41] Makefile: Do not generate files if "configure" has not been run yet, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 21/41] tcg: move tcg related files into accel/tcg/ subdirectory, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 20/41] accel: split the tcg accelerator from accel.c file, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 22/41] tcg: move tcg backend files into accel/tcg/, Paolo Bonzini, 2017/06/15
- [Qemu-devel] [PULL 17/41] hax-all: make async_safe_run_on_cpu safe on HAX too, Paolo Bonzini, 2017/06/15