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/virtualizationmanager/src/debug_config.rs b/virtualizationmanager/src/debug_config.rs
index a2ea40d..6b74353 100644
--- a/virtualizationmanager/src/debug_config.rs
+++ b/virtualizationmanager/src/debug_config.rs
@@ -26,6 +26,7 @@
use std::fs;
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
+use vmconfig::get_debug_level;
const CUSTOM_DEBUG_POLICY_OVERLAY_SYSPROP: &str =
"hypervisor.virtualizationmanager.debug_policy.path";
@@ -157,10 +158,7 @@
impl DebugConfig {
pub fn new(config: &VirtualMachineConfig) -> Self {
- let debug_level = match config {
- VirtualMachineConfig::AppConfig(config) => config.debugLevel,
- _ => DebugLevel::NONE,
- };
+ let debug_level = get_debug_level(config).unwrap_or(DebugLevel::NONE);
let dp_sysprop = system_properties::read(CUSTOM_DEBUG_POLICY_OVERLAY_SYSPROP);
let custom_dp = dp_sysprop.unwrap_or_else(|e| {