mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
main: clarify config parsing control flow
It was a bit difficult to see that the config parsing errors would be printed out before init_log(); split it into a separate block to make it more understandable. BUG=b:239622092 TEST=tools/presubmit --all Change-Id: Id7fb76c706c2e9f5e0161dac28099bff95fd5f78 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774317 Reviewed-by: Dennis Kempin <denniskempin@google.com> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
f0d2ddddf5
commit
e6eeb715f3
1 changed files with 28 additions and 26 deletions
24
src/main.rs
24
src/main.rs
|
@ -79,10 +79,17 @@ fn run_vm<F: 'static>(cmd: RunCommand, log_config: LogConfig<F>) -> Result<Comma
|
||||||
where
|
where
|
||||||
F: Fn(&mut syslog::fmt::Formatter, &log::Record<'_>) -> std::io::Result<()> + Sync + Send,
|
F: Fn(&mut syslog::fmt::Formatter, &log::Record<'_>) -> std::io::Result<()> + Sync + Send,
|
||||||
{
|
{
|
||||||
match TryInto::<Config>::try_into(cmd) {
|
let cfg = match TryInto::<Config>::try_into(cmd) {
|
||||||
|
Ok(cfg) => cfg,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
return Err(anyhow!("{}", e));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
Ok(cfg) if executable_is_plugin(&cfg.executable_path) => {
|
if executable_is_plugin(&cfg.executable_path) {
|
||||||
match crosvm::plugin::run_config(cfg) {
|
let res = match crosvm::plugin::run_config(cfg) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("crosvm and plugin have exited normally");
|
info!("crosvm and plugin have exited normally");
|
||||||
Ok(CommandStatus::VmStop)
|
Ok(CommandStatus::VmStop)
|
||||||
|
@ -91,9 +98,10 @@ where
|
||||||
eprintln!("{:#}", e);
|
eprintln!("{:#}", e);
|
||||||
Err(e)
|
Err(e)
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(cfg) => {
|
|
||||||
#[cfg(feature = "crash-report")]
|
#[cfg(feature = "crash-report")]
|
||||||
crosvm::sys::setup_emulator_crash_reporting(&cfg)?;
|
crosvm::sys::setup_emulator_crash_reporting(&cfg)?;
|
||||||
|
|
||||||
|
@ -103,12 +111,6 @@ where
|
||||||
init_log(log_config, &cfg)?;
|
init_log(log_config, &cfg)?;
|
||||||
let exit_state = crate::sys::run_config(cfg);
|
let exit_state = crate::sys::run_config(cfg);
|
||||||
to_command_status(exit_state)
|
to_command_status(exit_state)
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("{}", e);
|
|
||||||
Err(anyhow!("{}", e))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop_vms(cmd: cmdline::StopCommand) -> std::result::Result<(), ()> {
|
fn stop_vms(cmd: cmdline::StopCommand) -> std::result::Result<(), ()> {
|
||||||
|
|
Loading…
Reference in a new issue