mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 20:19:07 +00:00
crosvm: default serial parameter num
field to 1 if not provided
If multiple serial parameters do not have `num` fields, or a different parameter has already defined serial num 1, then crosvm will show an error. BUG=chromium:974885 TEST=cargo test; emerge-sarien crosvm && cros deploy dut crosvm; Manual testing with and without num field in --serial parameter Change-Id: Ia80247e8d055179adfd9e7471a98e8a2923cf1f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1662773 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Trent Begin <tbegin@chromium.org>
This commit is contained in:
parent
bb340d9a94
commit
923bab011f
1 changed files with 8 additions and 3 deletions
11
src/main.rs
11
src/main.rs
|
@ -247,7 +247,7 @@ fn parse_serial_options(s: &str) -> argument::Result<SerialParameters> {
|
|||
let mut serial_setting = SerialParameters {
|
||||
type_: SerialType::Sink,
|
||||
path: None,
|
||||
num: 0,
|
||||
num: 1,
|
||||
console: false,
|
||||
};
|
||||
|
||||
|
@ -832,11 +832,11 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
|
|||
Argument::flag("cras-capture", "Enable capturing audio from CRAS server to the cras-audio device"),
|
||||
Argument::flag("null-audio", "Add an audio device to the VM that plays samples to /dev/null"),
|
||||
Argument::value("serial",
|
||||
"type=TYPE,[path=PATH,num=NUM,console]",
|
||||
"type=TYPE,[num=NUM,path=PATH,console]",
|
||||
"Comma seperated key=value pairs for setting up serial devices. Can be given more than once.
|
||||
Possible key values:
|
||||
type=(stdout,syslog,sink,file) - Where to route the serial device
|
||||
num=(1,2,3,4) - Serial Device Number
|
||||
num=(1,2,3,4) - Serial Device Number. If not provided, num will default to 1.
|
||||
path=PATH - The path to the file to write to when type=file
|
||||
console - Use this serial device as the guest console. Can only be given once. Will default to first serial port if not provided.
|
||||
"),
|
||||
|
@ -1417,6 +1417,11 @@ mod tests {
|
|||
parse_serial_options("type=syslog,num=1,console=true").expect("parse should have succeded");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_serial_valid_no_num() {
|
||||
parse_serial_options("type=syslog").expect("parse should have succeded");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_serial_invalid_type() {
|
||||
parse_serial_options("type=wormhole,num=1").expect_err("parse should have failed");
|
||||
|
|
Loading…
Reference in a new issue