diff options
author | Dmitry Torokhov <dtor@chromium.org> | 2019-12-11 13:36:08 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-17 09:56:47 +0000 |
commit | 0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15 (patch) | |
tree | f0b461098ba7a3151f519968a9f654d8696035ef /src/main.rs | |
parent | c689fd92e6ce9d5976a242e38877b92378d47284 (diff) | |
download | crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar.gz crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar.bz2 crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar.lz crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar.xz crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.tar.zst crosvm-0f4c5fff7a9a4283572b23d5ad9c9af6c125bb15.zip |
crosvm: plugin-mount-file and plugin-gid-map-file options
List of bind-mounts and gid maps can be quite long, so let's allow listing them in text files, when convenient. BUG=b:144454617 TEST=Run Plugin VM Change-Id: I1218dab5a7e87b9f1ba44de6828da890fddb99fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967785 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 65dbaea..0e11ee1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ pub mod panic_hook; use std::fmt; use std::fs::{File, OpenOptions}; +use std::io::{BufRead, BufReader}; use std::num::ParseIntError; use std::os::unix::io::{FromRawFd, RawFd}; use std::path::{Path, PathBuf}; @@ -818,10 +819,40 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: let mount = parse_plugin_mount_option(value.unwrap())?; cfg.plugin_mounts.push(mount); } + "plugin-mount-file" => { + let file = File::open(value.unwrap()).map_err(|_| argument::Error::InvalidValue { + value: value.unwrap().to_owned(), + expected: "unable to open `plugin-mount-file` file", + })?; + let reader = BufReader::new(file); + for l in reader.lines() { + let line = l.unwrap(); + let trimmed_line = line.trim_end_matches("#").trim(); + if !trimmed_line.is_empty() { + let mount = parse_plugin_mount_option(trimmed_line)?; + cfg.plugin_mounts.push(mount); + } + } + } "plugin-gid-map" => { let map = parse_plugin_gid_map_option(value.unwrap())?; cfg.plugin_gid_maps.push(map); } + "plugin-gid-map-file" => { + let file = File::open(value.unwrap()).map_err(|_| argument::Error::InvalidValue { + value: value.unwrap().to_owned(), + expected: "unable to open `plugin-gid-map-file` file", + })?; + let reader = BufReader::new(file); + for l in reader.lines() { + let line = l.unwrap(); + let trimmed_line = line.trim_end_matches("#").trim(); + if !trimmed_line.is_empty() { + let map = parse_plugin_gid_map_option(trimmed_line)?; + cfg.plugin_gid_maps.push(map); + } + } + } "vhost-net" => cfg.vhost_net = true, "tap-fd" => { cfg.tap_fd.push( @@ -1029,7 +1060,11 @@ writeback=BOOL - Indicates whether the VM can use writeback caching (default: fa #[cfg(feature = "plugin")] Argument::value("plugin-mount", "PATH:PATH:BOOL", "Path to be mounted into the plugin's root filesystem. Can be given more than once."), #[cfg(feature = "plugin")] + Argument::value("plugin-mount-file", "PATH", "Path to the file listing paths be mounted into the plugin's root filesystem. Can be given more than once."), + #[cfg(feature = "plugin")] Argument::value("plugin-gid-map", "GID:GID:INT", "Supplemental GIDs that should be mapped in plugin jail. Can be given more than once."), + #[cfg(feature = "plugin")] + Argument::value("plugin-gid-map-file", "PATH", "Path to the file listing supplemental GIDs that should be mapped in plugin jail. Can be given more than once."), Argument::flag("vhost-net", "Use vhost for networking."), Argument::value("tap-fd", "fd", |