summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-01-30 18:13:04 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-12 22:42:34 -0800
commitbb678718926888701eb17f1ba1c5721592d7f881 (patch)
tree9715d0e529544f6a043efb2ba20bcdba12b6cad0 /src/main.rs
parentcc30d58c18353905154173bab850d3610c7d01bc (diff)
downloadcrosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar.gz
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar.bz2
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar.lz
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar.xz
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.tar.zst
crosvm-bb678718926888701eb17f1ba1c5721592d7f881.zip
crosvm: support passing command line arguments to plugin process
This uses the same command line mechanism as the kernel command line
option. As a consequence, the Config field for the params is now a
vector of strings to accommodate potential whitespace in the individual
params.

TEST=cargo build --features plugin; ./build_test
BUG=chromium:800626

Change-Id: Ief20a55bf7ced23f64e5112e184dd714f050120a
Reviewed-on: https://chromium-review.googlesource.com/895415
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs
index 7e2d103..a3356d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -62,7 +62,7 @@ pub struct Config {
     vcpu_count: Option<u32>,
     memory: Option<usize>,
     kernel_path: PathBuf,
-    params: String,
+    params: Vec<String>,
     host_ip: Option<net::Ipv4Addr>,
     netmask: Option<net::Ipv4Addr>,
     mac_address: Option<String>,
@@ -82,7 +82,7 @@ impl Default for Config {
             vcpu_count: None,
             memory: None,
             kernel_path: PathBuf::default(),
-            params: String::new(),
+            params: Vec::new(),
             host_ip: None,
             netmask: None,
             mac_address: None,
@@ -146,10 +146,7 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
             }
         }
         "params" => {
-            if cfg.params.ends_with(|c| !char::is_whitespace(c)) {
-                cfg.params.push(' ');
-            }
-            cfg.params.push_str(&value.unwrap());
+            cfg.params.push(value.unwrap().to_owned());
         }
         "cpus" => {
             if cfg.vcpu_count.is_some() {
@@ -193,15 +190,9 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                 if cfg.disks.len() >= 26 {
                     return Err(argument::Error::TooManyArguments("ran out of letters for to assign to root disk".to_owned()));
                 }
-                let white = if cfg.params.ends_with(|c| !char::is_whitespace(c)) {
-                    " "
-                } else {
-                    ""
-                };
                 cfg.params
-                    .push_str(&format!("{}root=/dev/vd{} ro",
-                                       white,
-                                       char::from('a' as u8 + cfg.disks.len() as u8)));
+                    .push(format!("root=/dev/vd{} ro",
+                                  char::from('a' as u8 + cfg.disks.len() as u8)));
             }
             cfg.disks
                 .push(DiskOption {
@@ -329,7 +320,7 @@ fn run_vm(args: std::env::Args) -> i32 {
           Argument::short_value('p',
                                 "params",
                                 "PARAMS",
-                                "Extra kernel command line arguments. Can be given more than once."),
+                                "Extra kernel or plugin command line arguments. Can be given more than once."),
           Argument::short_value('c', "cpus", "N", "Number of VCPUs. (default: 1)"),
           Argument::short_value('m',
                                 "mem",