diff options
author | Jorge E. Moreira <jemoreira@google.com> | 2019-02-12 16:43:05 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-14 05:27:29 -0800 |
commit | b795280ddcd9d290d89ff0e284bc12ae91640baf (patch) | |
tree | 1e239b71a3ac253b91410c87543c396cbfa950fb /src/main.rs | |
parent | 348ccf1102895acf5a064d388ab8249c575ccafb (diff) | |
download | crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar.gz crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar.bz2 crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar.lz crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar.xz crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.tar.zst crosvm-b795280ddcd9d290d89ff0e284bc12ae91640baf.zip |
Add support for multiple network interfaces
Allow --tap-fd to be given mutliple times, a different virtual network card will be added each time the flag is given. Additionally, --tap-fd is no longer mutually exclusive with --host-ip, etc. Bug=chromium:931470 Test=booted cuttlefish device with multiple network cards Change-Id: I4108f97c7f4b19db12fcb3c533088a04a58e56db Reviewed-on: https://chromium-review.googlesource.com/1469222 Commit-Ready: Jorge Moreira Broche <jemoreira@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Jorge Moreira Broche <jemoreira@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs index 16dcf10..3e3afef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,7 +108,7 @@ pub struct Config { netmask: Option<net::Ipv4Addr>, mac_address: Option<net_util::MacAddress>, vhost_net: bool, - tap_fd: Option<RawFd>, + tap_fd: Vec<RawFd>, cid: Option<u64>, wayland_socket_path: Option<PathBuf>, wayland_dmabuf: bool, @@ -143,7 +143,7 @@ impl Default for Config { netmask: None, mac_address: None, vhost_net: false, - tap_fd: None, + tap_fd: Vec::new(), cid: None, gpu: false, wayland_socket_path: None, @@ -505,21 +505,15 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: } "vhost-net" => cfg.vhost_net = true, "tap-fd" => { - if cfg.tap_fd.is_some() { - return Err(argument::Error::TooManyArguments( - "`tap-fd` alread given".to_owned(), - )); - } - cfg.tap_fd = - Some( - value - .unwrap() - .parse() - .map_err(|_| argument::Error::InvalidValue { - value: value.unwrap().to_owned(), - expected: "this value for `tap-fd` must be an unsigned integer", - })?, - ); + cfg.tap_fd.push( + value + .unwrap() + .parse() + .map_err(|_| argument::Error::InvalidValue { + value: value.unwrap().to_owned(), + expected: "this value for `tap-fd` must be an unsigned integer", + })?, + ); } "gpu" => { cfg.gpu = true; @@ -632,7 +626,7 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> { Argument::flag("vhost-net", "Use vhost for networking."), Argument::value("tap-fd", "fd", - "File descriptor for configured tap device. Mutually exclusive with `host_ip`, `netmask`, and `mac`."), + "File descriptor for configured tap device. A different virtual network card will be added each time this argument is given."), #[cfg(feature = "gpu")] Argument::flag("gpu", "(EXPERIMENTAL) enable virtio-gpu device"), Argument::value("evdev", "PATH", "Path to an event device node. The device will be grabbed (unusable from the host) and made available to the guest with the same configuration it shows on the host"), @@ -673,14 +667,6 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> { "`plugin-root` requires `plugin`".to_owned(), )); } - if cfg.tap_fd.is_some() - && (cfg.host_ip.is_some() || cfg.netmask.is_some() || cfg.mac_address.is_some()) - { - return Err(argument::Error::TooManyArguments( - "`tap_fd` and any of `host_ip`, `netmask`, or `mac` are mutually exclusive" - .to_owned(), - )); - } Ok(()) }); |