mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 20:19:07 +00:00
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>
This commit is contained in:
parent
06944ec625
commit
6a8cd101b2
1 changed files with 8 additions and 5 deletions
13
src/main.rs
13
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."),
|
||||
|
|
Loading…
Reference in a new issue