vmm: memory: Use fine grained mmap wrapper

In order to anticipate the need for special mmap flags when memory
mapping the guest RAM, we need to switch from from_file() wrapper to
build() wrapper.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-04-07 10:32:54 +02:00
parent f0ab002ef1
commit be4e1e8712

View File

@ -436,9 +436,15 @@ impl MemoryManager {
f.set_len(size as u64).map_err(Error::SharedFileSetLen)?;
let mmap_flags = libc::MAP_NORESERVE | libc::MAP_SHARED;
GuestRegionMmap::new(
MmapRegion::from_file(FileOffset::new(f, 0), size)
.map_err(Error::GuestMemoryRegion)?,
MmapRegion::build(
Some(FileOffset::new(f, 0)),
size,
libc::PROT_READ | libc::PROT_WRITE,
mmap_flags,
)
.map_err(Error::GuestMemoryRegion)?,
start_addr,
)
.map_err(Error::GuestMemory)?