mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
crosvm: Support "=" in --serial args
The --serial option does not support args that have the '=' character (or the ',' character for that matter, but we dont mind so much there). This became a problem after crreev.com/c/2386885 made all encoded VM names include padding, as the padding charcter '=' caused serial paths like "foo=.log" to be interpreted as "foo". This was not noticed because: - Logging is not covered in automated testing. - My vm name was "brl" in manual testing, which does not require padding when b64 encoded. BUG=b:168859379 TEST=vmc start termina; grep maitred /run/daemon.../log/dGVybWluYQ==.log Change-Id: I07ffd1c76abab1866a8fb54763605c0ef8733776 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2417797 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Nic Hollingum <hollingum@google.com> Reviewed-by: Nicholas Verne <nverne@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Fergus Dall <sidereal@google.com>
This commit is contained in:
parent
2296c987cd
commit
c76c2dae56
1 changed files with 8 additions and 1 deletions
|
@ -401,7 +401,7 @@ fn parse_serial_options(s: &str) -> argument::Result<SerialParameters> {
|
|||
|
||||
let opts = s
|
||||
.split(',')
|
||||
.map(|frag| frag.split('='))
|
||||
.map(|frag| frag.splitn(2, '='))
|
||||
.map(|mut kv| (kv.next().unwrap_or(""), kv.next().unwrap_or("")));
|
||||
|
||||
for (k, v) in opts {
|
||||
|
@ -2194,6 +2194,13 @@ mod tests {
|
|||
parse_serial_options("type=syslog").expect("parse should have succeded");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_serial_equals_in_value() {
|
||||
let parsed = parse_serial_options("type=syslog,path=foo=bar==.log")
|
||||
.expect("parse should have succeded");
|
||||
assert_eq!(parsed.path, Some(PathBuf::from("foo=bar==.log")));
|
||||
}
|
||||
|
||||
#[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