mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
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>
This commit is contained in:
parent
ec9a99146e
commit
cef3558006
1 changed files with 6 additions and 2 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue