From 29b74804e1ca61fcb51938f12db1cb75e444bc78 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 25 Sep 2020 09:32:48 +0100 Subject: [PATCH] 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 --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 62664d7ae..9d2246034 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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,