mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
main: add safety comments
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
145df4b689
commit
d5f294b326
@ -453,6 +453,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
|||||||
.convert("fd")
|
.convert("fd")
|
||||||
.map_err(Error::ParsingEventMonitor)?
|
.map_err(Error::ParsingEventMonitor)?
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
// SAFETY: fd is valid
|
||||||
unsafe { File::from_raw_fd(fd) }
|
unsafe { File::from_raw_fd(fd) }
|
||||||
} else if parser.is_set("path") {
|
} else if parser.is_set("path") {
|
||||||
std::fs::OpenOptions::new()
|
std::fs::OpenOptions::new()
|
||||||
@ -592,6 +593,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result<Option<String>, Error> {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Ensure all created files (.e.g sockets) are only accessible by this user
|
// Ensure all created files (.e.g sockets) are only accessible by this user
|
||||||
|
// SAFETY: trivially safe
|
||||||
let _ = unsafe { libc::umask(0o077) };
|
let _ = unsafe { libc::umask(0o077) };
|
||||||
|
|
||||||
let (default_vcpus, default_memory, default_rng) = prepare_default_values();
|
let (default_vcpus, default_memory, default_rng) = prepare_default_values();
|
||||||
@ -607,6 +609,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// SAFETY: trivially safe
|
||||||
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0;
|
let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0;
|
||||||
if on_tty {
|
if on_tty {
|
||||||
// Don't forget to set the terminal in canonical mode
|
// Don't forget to set the terminal in canonical mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user