From 07cbe73dc83ea3c15a3b835b432e26c3502c3908 Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Wed, 30 Aug 2023 16:34:36 +0200 Subject: [PATCH] scmi: Improve output on backend configuration error Print a properly formatted error to both the log and terminal. Signed-off-by: Milan Zamazal --- crates/scmi/src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/scmi/src/main.rs b/crates/scmi/src/main.rs index 36c9561..8a925d8 100644 --- a/crates/scmi/src/main.rs +++ b/crates/scmi/src/main.rs @@ -107,8 +107,12 @@ impl TryFrom for VuScmiConfig { fn start_backend(config: VuScmiConfig) -> Result<()> { loop { debug!("Starting backend"); - // TODO: Print a nice error message on backend configuration failure. - let backend = Arc::new(RwLock::new(VuScmiBackend::new(&config).unwrap())); + let backend_instance = VuScmiBackend::new(&config); + if let Err(error) = backend_instance { + return Err(error.to_string()); + } + + let backend = Arc::new(RwLock::new(backend_instance.unwrap())); let listener = Listener::new(config.socket_path.clone(), true).unwrap(); let mut daemon = VhostUserDaemon::new( "vhost-device-scmi".to_owned(), @@ -163,6 +167,7 @@ fn main() { Ok(config) => { if let Err(error) = start_backend(config) { error!("{error}"); + println!("{error}"); exit(1); } }