scmi: Improve output on backend configuration error

Print a properly formatted error to both the log and terminal.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
Milan Zamazal 2023-08-30 16:34:36 +02:00 committed by Alex Bennée
parent 0261d315ac
commit 07cbe73dc8

View File

@ -107,8 +107,12 @@ impl TryFrom<ScmiArgs> 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);
}
}