mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
memory_manager: use MFD_CLOEXEC flag when creating memory fd
Until there is a need for sharing the memory fd with a child process, we should err on the safe side to close it on exec. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
0cd6d96874
commit
b99b2bc990
@ -1252,9 +1252,8 @@ impl MemoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let fd = Self::memfd_create(
|
let flags = libc::MFD_CLOEXEC
|
||||||
&ffi::CString::new("ch_ram").unwrap(),
|
| if hugepages {
|
||||||
if hugepages {
|
|
||||||
libc::MFD_HUGETLB
|
libc::MFD_HUGETLB
|
||||||
| if let Some(hugepage_size) = hugepage_size {
|
| if let Some(hugepage_size) = hugepage_size {
|
||||||
/*
|
/*
|
||||||
@ -1274,9 +1273,9 @@ impl MemoryManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
},
|
};
|
||||||
)
|
let fd = Self::memfd_create(&ffi::CString::new("ch_ram").unwrap(), flags)
|
||||||
.map_err(Error::SharedFileCreate)?;
|
.map_err(Error::SharedFileCreate)?;
|
||||||
|
|
||||||
let f = unsafe { File::from_raw_fd(fd) };
|
let f = unsafe { File::from_raw_fd(fd) };
|
||||||
f.set_len(size as u64).map_err(Error::SharedFileSetLen)?;
|
f.set_len(size as u64).map_err(Error::SharedFileSetLen)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user