diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2020-05-19 00:36:39 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-29 23:19:05 +0000 |
commit | cef3558006302ae6a3eda7d43ac1b7bec75b2f7e (patch) | |
tree | 968d8575f1c87e2ab573d898b642f688e0992e25 | |
parent | ec9a99146e035ad327afb8c1f63e50b9da055c12 (diff) | |
download | crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar.gz crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar.bz2 crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar.lz crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar.xz crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.tar.zst crosvm-cef3558006302ae6a3eda7d43ac1b7bec75b2f7e.zip |
arch: serial: open file outputs for append
When opening the same output file for two serial devices (earlycon and console), the output would be overwritten by the later device. Change the file creation to use append mode so that the output file contains all of the logs from both devices instead of overwriting it. Tested with: crosvm run \ --serial hardware=serial,type=file,console=false,earlycon=true,path=test.log \ --serial hardware=virtio-console,type=file,console=true,stdin=true,path=test.log \ vm_kernel BUG=None TEST=see above - verify log contains earlycon and console output Change-Id: I14dab9eaf56dbb0ae410215324b20b34fea723ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208712 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
-rw-r--r-- | arch/src/serial.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/src/serial.rs b/arch/src/serial.rs index f24f4bc..b817cfd 100644 --- a/arch/src/serial.rs +++ b/arch/src/serial.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use std::fmt::{self, Display}; -use std::fs::File; +use std::fs::{File, OpenOptions}; use std::io::{self, stdin, stdout}; use std::os::unix::io::{AsRawFd, RawFd}; use std::path::PathBuf; @@ -170,7 +170,11 @@ impl SerialParameters { } SerialType::File => match &self.path { Some(path) => { - let file = File::create(path.as_path()).map_err(Error::FileError)?; + let file = OpenOptions::new() + .append(true) + .create(true) + .open(path.as_path()) + .map_err(Error::FileError)?; keep_fds.push(file.as_raw_fd()); Some(Box::new(file)) } |