Stop writing VM logs to files
The original reason was to allow us to direct potentially sensitive
logs to a well-protected location even on production devices.
But the current state is that the logs are only produced from debug
VMs, which we don't use in production. And it just means that when we
have test failures, we often don't see the logs that would tell us
what is going wrong.
Instead, just allow the logs to be sent to logcat. Get rid of test
code that attempted to preserve the now non-existent log files.
Bug: 275469579
Test: atest ComposBenchmarkApp; see VM logs in logcat
Test: composd test-compile; see VM logs in logcat
Change-Id: Ifa84b78b641a92b9f6a5290dfd6f3e169c20d53c
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index 96c8147..bf4c678 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -19,7 +19,7 @@
use crate::timeouts::TIMEOUTS;
use crate::{
get_vm_config_path, BUILD_MANIFEST_APK_PATH, BUILD_MANIFEST_SYSTEM_EXT_APK_PATH,
- COMPOS_APEX_ROOT, COMPOS_DATA_ROOT, COMPOS_VSOCK_PORT,
+ COMPOS_APEX_ROOT, COMPOS_VSOCK_PORT,
};
use android_system_virtualizationservice::aidl::android::system::virtualizationservice::{
CpuTopology::CpuTopology,
@@ -80,7 +80,6 @@
let instance_fd = ParcelFileDescriptor::new(instance_image);
let apex_dir = Path::new(COMPOS_APEX_ROOT);
- let data_dir = Path::new(COMPOS_DATA_ROOT);
let config_apk = locate_config_apk(apex_dir)?;
let apk_fd = File::open(config_apk).context("Failed to open config APK file")?;
@@ -110,18 +109,6 @@
let debug_level = if parameters.debug_mode { DebugLevel::FULL } else { DebugLevel::NONE };
- let (console_fd, log_fd) = if debug_level == DebugLevel::NONE {
- (None, None)
- } else {
- // Console output and the system log output from the VM are redirected to file.
- let console_fd = File::create(data_dir.join("vm_console.log"))
- .context("Failed to create console log file")?;
- let log_fd = File::create(data_dir.join("vm.log"))
- .context("Failed to create system log file")?;
- info!("Running in debug level {:?}", debug_level);
- (Some(console_fd), Some(log_fd))
- };
-
let cpu_topology = match parameters.cpu_topology {
VmCpuTopology::OneCpu => CpuTopology::ONE_CPU,
VmCpuTopology::MatchHost => CpuTopology::MATCH_HOST,
@@ -143,6 +130,8 @@
gdbPort: 0, // Don't start gdb-server
});
+ // Let logs go to logcat.
+ let (console_fd, log_fd) = (None, None);
let callback = Box::new(Callback {});
let instance = VmInstance::create(service, &config, console_fd, log_fd, Some(callback))
.context("Failed to create VM")?;
diff --git a/compos/tests/java/android/compos/test/ComposTestCase.java b/compos/tests/java/android/compos/test/ComposTestCase.java
index 4e3d0a8..8a1b41a 100644
--- a/compos/tests/java/android/compos/test/ComposTestCase.java
+++ b/compos/tests/java/android/compos/test/ComposTestCase.java
@@ -27,7 +27,6 @@
import com.android.microdroid.test.host.CommandRunner;
import com.android.microdroid.test.host.MicrodroidHostTestCaseBase;
-import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.FileInputStreamSource;
import com.android.tradefed.result.LogDataType;
@@ -95,8 +94,6 @@
public void tearDown() throws Exception {
killVmAndReconnectAdb();
- archiveVmLogsThenDelete("teardown");
-
CommandRunner android = new CommandRunner(getDevice());
// Clear up any CompOS instance files we created
@@ -113,19 +110,6 @@
}
}
- private void archiveVmLogsThenDelete(String suffix) throws DeviceNotAvailableException {
- archiveLogThenDelete(
- mTestLogs,
- getDevice(),
- COMPOS_APEXDATA_DIR + "/vm_console.log",
- "vm_console.log-" + suffix + "-" + mTestName.getMethodName());
- archiveLogThenDelete(
- mTestLogs,
- getDevice(),
- COMPOS_APEXDATA_DIR + "/vm.log",
- "vm.log-" + suffix + "-" + mTestName.getMethodName());
- }
-
@Test
public void testOdrefreshSpeed() throws Exception {
getDevice().setProperty(SYSTEM_SERVER_COMPILER_FILTER_PROP_NAME, "speed");
@@ -170,10 +154,6 @@
}
killVmAndReconnectAdb();
- // These logs are potentially useful, capture them before they are overwritten by
- // compos_verify.
- archiveVmLogsThenDelete("compile");
-
// Expect the BCC extracted from the BCC to be well-formed.
assertVmBccIsValid();