diff options
author | Jason D. Clinton <jclinton@chromium.org> | 2017-09-27 22:04:03 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-02 16:32:12 -0800 |
commit | 865323d0ed8b6913ed7dfe6e31c3b86eb46775bd (patch) | |
tree | be835e928e8932ab66dc00412d5f96430289e94c /src | |
parent | 19e57b9532f9be830fab7fad685957afc8f5ab78 (diff) | |
download | crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar.gz crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar.bz2 crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar.lz crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar.xz crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.tar.zst crosvm-865323d0ed8b6913ed7dfe6e31c3b86eb46775bd.zip |
hw/virtio/vhost: Add simple tests backed by fakes
This slightly advances the use of fakes to test higher level application logic. The fakes are rudimentary at this point, but I wanted to get feedback on the addition of generics in order to facilitate swaping concrete implementations out with fakes in higher level code. BUG=none TEST=./build_test and cargo test -p crosvm -p data_model -p syscall_defines -p kernel_loader -p net_util -p x86_64 -p virtio_sys -p kvm_sys -p vhost -p io_jail -p net_sys -p sys_util -p kvm Change-Id: Ib64581014391f49cff30ada10677bbbcd0088f20 Reviewed-on: https://chromium-review.googlesource.com/689740 Commit-Ready: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/linux.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/linux.rs b/src/linux.rs index abf39f9..1d0a311 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -22,9 +22,11 @@ use io_jail::{self, Minijail}; use kernel_cmdline; use kernel_loader; use kvm::*; +use net_util::Tap; use qcow::{self, QcowFile}; use sys_util::*; use sys_util; +use vhost; use vm_control::VmRequest; use Config; @@ -352,10 +354,10 @@ fn setup_mmio_bus(cfg: &Config, if let Some(host_ip) = cfg.host_ip { if let Some(netmask) = cfg.netmask { let net_box: Box<devices::virtio::VirtioDevice> = if cfg.vhost_net { - Box::new(devices::virtio::vhost::Net::new(host_ip, netmask, &mem) - .map_err(Error::VhostNetDeviceNew)?) + Box::new(devices::virtio::vhost::Net::<Tap, vhost::Net<Tap>>::new(host_ip, netmask, &mem) + .map_err(|e| Error::VhostNetDeviceNew(e))?) } else { - Box::new(devices::virtio::Net::new(host_ip, netmask) + Box::new(devices::virtio::Net::<Tap>::new(host_ip, netmask) .map_err(|e| Error::NetDeviceNew(e))?) }; diff --git a/src/main.rs b/src/main.rs index fb2d151..4248195 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,9 +12,11 @@ extern crate kvm; extern crate x86_64; extern crate kernel_loader; extern crate byteorder; +extern crate net_util; extern crate qcow; #[macro_use] extern crate sys_util; +extern crate vhost; extern crate vm_control; extern crate data_model; |