diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-06-26 15:17:46 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-27 17:29:53 +0000 |
commit | 6a8cd101b2e81e0478fb0fe6659759bad470e213 (patch) | |
tree | 6d0e51ab0cfd3af43fc67adf98f7c62275d8959c /src/main.rs | |
parent | 06944ec625ba3b546d7e99da235dca3a19b0aa00 (diff) | |
download | crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar.gz crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar.bz2 crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar.lz crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar.xz crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.tar.zst crosvm-6a8cd101b2e81e0478fb0fe6659759bad470e213.zip |
main: add --rwroot option to run
This allows specifying a read-write rootfs (rather than read-only as with --root), including the automatic kernel command line additions normally added by --root. BUG=None TEST=Boot crosvm with --rwroot and write to root filesystem Change-Id: I6a3dc9176bffdefe664139cb33bf3e65a751dbf2 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679531 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 64001a4..ee02b57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -418,7 +418,8 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: syslog::set_proc_name(value.unwrap()); cfg.syslog_tag = Some(value.unwrap().to_owned()); } - "root" | "disk" | "rwdisk" | "qcow" | "rwqcow" => { + "root" | "rwroot" | "disk" | "rwdisk" | "qcow" | "rwqcow" => { + let read_only = !name.starts_with("rw"); let disk_path = PathBuf::from(value.unwrap()); if !disk_path.exists() { return Err(argument::Error::InvalidValue { @@ -426,20 +427,21 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: expected: "this disk path does not exist", }); } - if name == "root" { + if name.ends_with("root") { if cfg.disks.len() >= 26 { return Err(argument::Error::TooManyArguments( "ran out of letters for to assign to root disk".to_owned(), )); } cfg.params.push(format!( - "root=/dev/vd{} ro", - char::from(b'a' + cfg.disks.len() as u8) + "root=/dev/vd{} {}", + char::from(b'a' + cfg.disks.len() as u8), + if read_only { "ro" } else { "rw" } )); } cfg.disks.push(DiskOption { path: disk_path, - read_only: !name.starts_with("rw"), + read_only, }); } "pmem-device" | "rw-pmem-device" => { @@ -817,6 +819,7 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> { "root", "PATH", "Path to a root disk image. Like `--disk` but adds appropriate kernel command line option."), + Argument::value("rwroot", "PATH", "Path to a writable root disk image."), Argument::short_value('d', "disk", "PATH", "Path to a disk image."), Argument::value("qcow", "PATH", "Path to a qcow2 disk image. (Deprecated; use --disk instead.)"), Argument::value("rwdisk", "PATH", "Path to a writable disk image."), |