From 22cc96494f7fe6c512a6ba3327e541dc7e7357fe Mon Sep 17 00:00:00 2001 From: Rafael Mendonca Date: Mon, 22 May 2023 11:36:07 -0300 Subject: [PATCH] main: Fix error propagation if starting the VM fails Commit 21d40d7 ("main: reset tty if starting the VM fails") changed start_vmm() to join the vmm thread if an error happens after the vmm thread is started. The implementation put all the error-prone code that is run after the vmm is started in a closure, to be able to always join the vmm thread, regardless of any error happening. However, it missed propagating the error that might happen inside the closure back to the main function, after joining the vmm thread. For some cmd line options, the above issue inhibits proper error reporting when starting a VM with invalid commands, as many parameters are parsed after the vmm is started, thus if such parsing fails, no error will be reported back to the user. See: #5435 Fixes: 21d40d7 ("main: reset tty if starting the VM fails") Signed-off-by: Rafael Mendonca --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d15ff380f..bcca2900f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -573,7 +573,7 @@ fn start_vmm(toplevel: TopLevel) -> Result, Error> { .map_err(Error::ThreadJoin)? .map_err(Error::VmmThread)?; - Ok(api_socket_path) + r.map(|_| api_socket_path) } fn main() {