vmconfig: Introduce get_debug_level()
Add helper function to centralize deducing the debug level from a VM
config (either app or raw).
Test: m libvmconfig vm virtmgr
Change-Id: Ia04202fe3b1659b0428fd772e83e075d329f4cca
diff --git a/vm/src/run.rs b/vm/src/run.rs
index 07e0276..ca3e857 100644
--- a/vm/src/run.rs
+++ b/vm/src/run.rs
@@ -39,7 +39,7 @@
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::{Path, PathBuf};
use vmclient::{ErrorCode, VmInstance};
-use vmconfig::{open_parcel_file, VmConfig};
+use vmconfig::{get_debug_level, open_parcel_file, VmConfig};
use zip::ZipArchive;
/// Run a VM from the given APK, idsig, and config.
@@ -315,10 +315,8 @@
.context("Failed to create VM")?;
vm.start().context("Failed to start VM")?;
- let debug_level = match config {
- VirtualMachineConfig::AppConfig(config) => config.debugLevel,
- _ => DebugLevel::NONE,
- };
+ let debug_level = get_debug_level(config).unwrap_or(DebugLevel::NONE);
+
println!(
"Created {} from {} with CID {}, state is {}.",
if debug_level == DebugLevel::FULL { "debuggable VM" } else { "VM" },