diff options
author | Elie Kheirallah <khei@google.com> | 2024-04-16 17:16:34 +0000 |
---|---|---|
committer | Elie Kheirallah <khei@google.com> | 2024-04-16 22:04:42 +0000 |
commit | a522bcb3f662cabd435ec0459daebf290f8eec9f (patch) | |
tree | 2fc5f8b9119d35962ffc8e4712d0d75a5a32d2e6 | |
parent | a5785dcb15b2d65edc6ccd59a0e449fbedcdd243 (diff) | |
download | cuttlefish-a522bcb3f662cabd435ec0459daebf290f8eec9f.tar.gz |
Preserve legacy logs on restore
Restore was deleting legacy logs (kernel, launcher, etc). Preserve those
logs.
Check if symlinks exist, and delete them.
Bug: 333101647
Test: cvd start, cvd snapshot, cvd start --snapshot_path, inspect
launcher.log and see the previous start of the device that does not have
the argument "--restore".
Change-Id: Iccfd7fc4a84609a80935269e25398fb0df2e584d
-rw-r--r-- | host/commands/assemble_cvd/assemble_cvd.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc index e396cb0ed..5ad253b71 100644 --- a/host/commands/assemble_cvd/assemble_cvd.cc +++ b/host/commands/assemble_cvd/assemble_cvd.cc @@ -132,6 +132,10 @@ Result<void> CreateLegacySymlinks( for (const auto& log_file : log_files) { auto symlink_location = instance.PerInstancePath(log_file.c_str()); auto log_target = "logs/" + log_file; // Relative path + if (FileExists(symlink_location, /* follow_symlinks */ false)) { + CF_EXPECT(RemoveFile(symlink_location), + "Failed to remove symlink " << symlink_location); + } if (symlink(log_target.c_str(), symlink_location.c_str()) != 0) { return CF_ERRNO("symlink(\"" << log_target << ", " << symlink_location << ") failed"); @@ -244,6 +248,16 @@ Result<std::set<std::string>> PreservingOnResume( preserving.insert("vbmeta.img"); preserving.insert("oemlock_secure"); preserving.insert("oemlock_insecure"); + // Preserve logs if restoring from a snapshot. + if (!snapshot_path.empty()) { + preserving.insert("kernel.log"); + preserving.insert("launcher.log"); + preserving.insert("logcat"); + preserving.insert("modem_simulator.log"); + preserving.insert("crosvm_openwrt.log"); + preserving.insert("crosvm_openwrt_boot.log"); + preserving.insert("metrics.log"); + } for (int i = 0; i < modem_simulator_count; i++) { std::stringstream ss; ss << "iccprofile_for_sim" << i << ".xml"; |