src: Add integration test for vhost-user-net backend

An integration test relying on the new vhost-user-net backend now
replaces the previous test using the QEMU test backend. This allows
us to avoid building the QEMU backend, and we now really exercise the
vhost-user-net implementation as it is used for the ssh communication
in this test.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Cathy Zhang 2019-09-30 09:50:45 +08:00 committed by Sebastien Boeuf
parent f6d1a9d9b8
commit 8c33eb3069
2 changed files with 21 additions and 15 deletions

View File

@ -78,7 +78,6 @@ if [ ! -f "$VMLINUX_IMAGE" ]; then
fi
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
VUBRIDGE="$WORKLOADS_DIR/vubridge"
VUBD="$WORKLOADS_DIR/vubd"
QEMU_DIR="qemu_build"
if [ ! -f "$VIRTIOFSD" ] || [ ! -f "$VUBRIDGE" ] || [ ! -f "$VUBD" ]; then
@ -86,9 +85,8 @@ if [ ! -f "$VIRTIOFSD" ] || [ ! -f "$VUBRIDGE" ] || [ ! -f "$VUBD" ]; then
git clone --depth 1 "https://github.com/sboeuf/qemu.git" -b "virtio-fs" $QEMU_DIR
pushd $QEMU_DIR
./configure --prefix=$PWD --target-list=x86_64-softmmu
make virtiofsd tests/vhost-user-bridge vhost-user-blk -j `nproc`
make virtiofsd vhost-user-blk -j `nproc`
cp virtiofsd $VIRTIOFSD
cp tests/vhost-user-bridge $VUBRIDGE
cp vhost-user-blk $VUBD
popd
rm -rf $QEMU_DIR
@ -141,6 +139,7 @@ sudo ip link set vfio-tap1 up
cargo build
sudo setcap cap_net_admin+ep target/debug/cloud-hypervisor
sudo setcap cap_net_admin+ep target/debug/vhost_user_net
# We always copy a fresh version of our binary for our L2 guest.
cp target/debug/cloud-hypervisor $VFIO_DIR

View File

@ -1237,15 +1237,18 @@ mod tests {
let mut clear = ClearDiskConfig::new();
let guest = Guest::new(&mut clear);
let mut workload_path = dirs::home_dir().unwrap();
workload_path.push("workloads");
let mut vubridge_path = workload_path.clone();
vubridge_path.push("vubridge");
let vubridge_path = String::from(vubridge_path.to_str().unwrap());
// Start the daemon
let mut daemon_child = Command::new(vubridge_path.as_str()).spawn().unwrap();
let mut daemon_child = Command::new("target/debug/vhost_user_net")
.args(&[
"--backend",
format!(
"ip={},mask=255.255.255.0,sock=/tmp/vunet.sock",
guest.network.host_ip
)
.as_str(),
])
.spawn()
.unwrap();
let mut cloud_child = Command::new("target/debug/cloud-hypervisor")
.args(&["--cpus", "1"])
@ -1266,13 +1269,17 @@ mod tests {
])
.args(&[
"--vhost-user-net",
"mac=52:54:00:02:d9:01,sock=/tmp/vubr.sock",
format!("mac={},sock=/tmp/vunet.sock", guest.network.guest_mac).as_str(),
])
.args(&["--net", guest.default_net_string().as_str()])
.spawn()
.unwrap();
// 2 network interfaces + default localhost ==> 3 interfaces
// 1 network interface + default localhost ==> 2 interfaces
// It's important to note that this test is fully exercising the
// vhost-user-net implementation and the associated backend since
// it does not define any --net network interface. That means all
// the ssh communication in that test happens through the network
// interface backed by vhost-user-net.
aver_eq!(
tb,
guest
@ -1281,7 +1288,7 @@ mod tests {
.trim()
.parse::<u32>()
.unwrap_or_default(),
3
2
);
guest.ssh_command("sudo shutdown -h now")?;