main: Improve the error reporting when creating the hypervisor object

The ::new() does very little beyond trying to open the /dev/kvm device
so provide a hint to the user about what has gone wrong.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-09-25 09:32:48 +01:00 committed by Sebastien Boeuf
parent 1d3c3bc6ec
commit 29b74804e1

View File

@ -324,7 +324,16 @@ fn start_vmm(cmd_arguments: ArgMatches) {
} else {
SeccompAction::Trap
};
let hypervisor = hypervisor::new().unwrap();
let hypervisor = match hypervisor::new() {
Ok(h) => h,
Err(e) => {
eprintln!(
"Failed to open hypervisor interface (is /dev/kvm available?): {:?}",
e
);
process::exit(1);
}
};
let vmm_thread = match vmm::start_vmm_thread(
env!("CARGO_PKG_VERSION").to_string(),
api_socket_path,