From efec33af6fb96e4604e386ae9b6b37b0240b8fab Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Thu, 20 Oct 2022 12:53:39 +0900 Subject: [PATCH] crosvm: add `--block` argument to the `run` command We currently have 4 different arguments for specifying block devices: `disk`, `rwdisk`, `root`, and `rwroot`. These arguments basically do the same thing save for setting an additional flag to the disk configuration. This is both inefficient and confusing, so add a new `block` argument that allows to specify both the root and read-only properties as flags. It works similarly to the argument of the same name of the `devices` command and is easier to use in the context of a configuration file. We will eventually deprecate the 4 previous arguments after all users have transitioned to the new one. Change-Id: I87451aee57c714b5d47df9d8823c0b769137d426 BUG=b:218223240 TEST=`--block PATH,root` can be specified in place of `--rwroot PATH` and the right device is mounted as root, read-write. Change-Id: Ic186616344abac8af86040fc6b1613fd8e66a6a0 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3970364 Reviewed-by: Keiichi Watanabe Commit-Queue: Alexandre Courbot Reviewed-by: Daniel Verkamp --- src/crosvm/cmdline.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs index f15fcbdd90..1879e2e4c5 100644 --- a/src/crosvm/cmdline.rs +++ b/src/crosvm/cmdline.rs @@ -591,6 +591,27 @@ pub struct RunCommand { /// path to BIOS/firmware ROM pub bios: Option, + #[argh(option, arg_name = "PATH[,key=value[,key=value[,...]]]")] + /// parameters for setting up a block device. + /// Valid keys: + /// path=PATH - Path to the disk image. Can be specified + /// without the key as the first argument. + /// ro=BOOL - Whether the block should be read-only. + /// (default: false) + /// root=BOOL - Whether the block device should be mounted + /// as the root filesystem. This will add the required + /// parameters to the kernel command-line. Can only be + /// specified once. (default: false) + /// sparse=BOOL - Indicates whether the disk should support + /// the discard operation. (default: true) + /// block_size=BYTES - Set the reported block size of the + /// disk. (default: 512) + /// id=STRING - Set the block device identifier to an ASCII + /// string, up to 20 characters. (default: no ID) + /// o_direct=BOOL - Use O_DIRECT mode to bypass page cache. + /// (default: false) + block: Vec, + #[argh(option, arg_name = "CID")] /// context ID for virtual sockets. pub cid: Option, @@ -1724,6 +1745,7 @@ impl TryFrom for super::config::Config { d.disk_option.root = false; d })) + .chain(cmd.block.into_iter()) .collect::>(); // Sort all our disks by index.