virtmgr: Support dumping guest DT for debugging
Give a way to make crosvm dump the guest DT it generated without needing
to recompile and/or reinstall any part of the stack, by detecting the
newly-introduced boolean system property
hypervisor.virtualizationmanager.dump_device_tree
which can be set on devices being debugged.
Note: this propery is redundant if you pass a path to dump the device
tree using --dump-device-tree
Bug: 335160369
Test: m virtmgr && TH
Test: adb shell setprop
hypervisor.virtualizationmanager.dump_device_tree true && /apex/.../vm
run-microdroid && check
/data/misc/virtualizationservice/CID/device_tree.dtb exists
Change-Id: I71ba56f14812ccb9bc5dab1ad3789656aa9a8460
diff --git a/android/virtmgr/src/debug_config.rs b/android/virtmgr/src/debug_config.rs
index 74559de..6e2bfef 100644
--- a/android/virtmgr/src/debug_config.rs
+++ b/android/virtmgr/src/debug_config.rs
@@ -30,6 +30,7 @@
const CUSTOM_DEBUG_POLICY_OVERLAY_SYSPROP: &str =
"hypervisor.virtualizationmanager.debug_policy.path";
+const DUMP_DT_SYSPROP: &str = "hypervisor.virtualizationmanager.dump_device_tree";
const DEVICE_TREE_EMPTY_TREE_SIZE_BYTES: usize = 100; // rough estimation.
struct DPPath {
@@ -183,6 +184,7 @@
#[derive(Debug, Default)]
pub struct DebugConfig {
pub debug_level: DebugLevel,
+ pub dump_device_tree: bool,
debug_policy: DebugPolicy,
}
@@ -193,8 +195,13 @@
info!("Debug policy is disabled");
Default::default()
});
+ let dump_dt_sysprop = system_properties::read_bool(DUMP_DT_SYSPROP, false);
+ let dump_device_tree = dump_dt_sysprop.unwrap_or_else(|e| {
+ warn!("Failed to read sysprop {DUMP_DT_SYSPROP}: {e}");
+ false
+ });
- Self { debug_level, debug_policy }
+ Self { debug_level, debug_policy, dump_device_tree }
}
fn get_debug_policy() -> Option<DebugPolicy> {