Address comments from previous commit
This address late comments from following commit.
c03f6617 Enable microdroid console output with debug level or debug
policy
Bug: 268265510
Test: atest
Change-Id: I911b5cd4e0e3d56da76625f9246c31c00246c9ec
diff --git a/pvmfw/src/debug_policy.rs b/pvmfw/src/debug_policy.rs
index 4cb338d..23d3e1d 100644
--- a/pvmfw/src/debug_policy.rs
+++ b/pvmfw/src/debug_policy.rs
@@ -203,7 +203,7 @@
disable_ramdump(fdt)?;
}
- // Handles conseole output in the debug policy
+ // Handles console output in the debug policy
if is_console_output_enabled(fdt)? {
enable_console_output(fdt)?;
info!("console output is enabled by debug policy");
diff --git a/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java b/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
index 1ada5a1..d0b7c0e 100644
--- a/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/PvmfwDebugPolicyHostTests.java
@@ -56,7 +56,6 @@
@NonNull private static final String MICRODROID_DEBUG_FULL = "full";
@NonNull private static final String MICRODROID_CONFIG_PATH = "assets/vm_config_apex.json";
@NonNull private static final String MICRODROID_LOG_PATH = TEST_ROOT + "log.txt";
- @NonNull private static final String MICRODROID_CONSOLE_PATH = TEST_ROOT + "console.txt";
private static final int BOOT_COMPLETE_TIMEOUT_MS = 30000; // 30 seconds
private static final int CONSOLE_OUTPUT_WAIT_MS = 5000; // 5 seconds
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 1781007..abc8091 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -1025,13 +1025,12 @@
return Ok(Some(clone_file(fd)?));
}
- if let VirtualMachineConfig::AppConfig(app_config) = config {
- if !should_prepare_console_output(app_config.debugLevel) {
- return Ok(None);
- }
- } else {
+ let VirtualMachineConfig::AppConfig(app_config) = config else {
return Ok(None);
- }
+ };
+ if !should_prepare_console_output(app_config.debugLevel) {
+ return Ok(None);
+ };
let (raw_read_fd, raw_write_fd) = pipe().map_err(|e| {
Status::new_service_specific_error_str(-1, Some(format!("Failed to create pipe: {:?}", e)))
diff --git a/virtualizationmanager/src/debug_config.rs b/virtualizationmanager/src/debug_config.rs
index 332df08..e494040 100644
--- a/virtualizationmanager/src/debug_config.rs
+++ b/virtualizationmanager/src/debug_config.rs
@@ -22,13 +22,11 @@
/// Get debug policy value in bool. It's true iff the value is explicitly set to <1>.
fn get_debug_policy_bool(path: &'static str) -> Option<bool> {
- if let Ok(mut file) = File::open(path) {
- let mut log: [u8; 4] = Default::default();
- file.read_exact(&mut log).map_err(|_| false).unwrap();
- // DT spec uses big endian although Android is always little endian.
- return Some(u32::from_be_bytes(log) == 1);
- }
- None
+ let mut file = File::open(path).ok()?;
+ let mut log: [u8; 4] = Default::default();
+ file.read_exact(&mut log).ok()?;
+ // DT spec uses big endian although Android is always little endian.
+ Some(u32::from_be_bytes(log) == 1)
}
/// Get whether console output should be configred for VM to leave console and adb log.