mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 16:01:15 +00:00
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:
parent
f6d1a9d9b8
commit
8c33eb3069
@ -78,7 +78,6 @@ if [ ! -f "$VMLINUX_IMAGE" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
||||||
VUBRIDGE="$WORKLOADS_DIR/vubridge"
|
|
||||||
VUBD="$WORKLOADS_DIR/vubd"
|
VUBD="$WORKLOADS_DIR/vubd"
|
||||||
QEMU_DIR="qemu_build"
|
QEMU_DIR="qemu_build"
|
||||||
if [ ! -f "$VIRTIOFSD" ] || [ ! -f "$VUBRIDGE" ] || [ ! -f "$VUBD" ]; then
|
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
|
git clone --depth 1 "https://github.com/sboeuf/qemu.git" -b "virtio-fs" $QEMU_DIR
|
||||||
pushd $QEMU_DIR
|
pushd $QEMU_DIR
|
||||||
./configure --prefix=$PWD --target-list=x86_64-softmmu
|
./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 virtiofsd $VIRTIOFSD
|
||||||
cp tests/vhost-user-bridge $VUBRIDGE
|
|
||||||
cp vhost-user-blk $VUBD
|
cp vhost-user-blk $VUBD
|
||||||
popd
|
popd
|
||||||
rm -rf $QEMU_DIR
|
rm -rf $QEMU_DIR
|
||||||
@ -141,6 +139,7 @@ sudo ip link set vfio-tap1 up
|
|||||||
|
|
||||||
cargo build
|
cargo build
|
||||||
sudo setcap cap_net_admin+ep target/debug/cloud-hypervisor
|
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.
|
# We always copy a fresh version of our binary for our L2 guest.
|
||||||
cp target/debug/cloud-hypervisor $VFIO_DIR
|
cp target/debug/cloud-hypervisor $VFIO_DIR
|
||||||
|
31
src/main.rs
31
src/main.rs
@ -1237,15 +1237,18 @@ mod tests {
|
|||||||
let mut clear = ClearDiskConfig::new();
|
let mut clear = ClearDiskConfig::new();
|
||||||
let guest = Guest::new(&mut clear);
|
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
|
// 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")
|
let mut cloud_child = Command::new("target/debug/cloud-hypervisor")
|
||||||
.args(&["--cpus", "1"])
|
.args(&["--cpus", "1"])
|
||||||
@ -1266,13 +1269,17 @@ mod tests {
|
|||||||
])
|
])
|
||||||
.args(&[
|
.args(&[
|
||||||
"--vhost-user-net",
|
"--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()
|
.spawn()
|
||||||
.unwrap();
|
.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!(
|
aver_eq!(
|
||||||
tb,
|
tb,
|
||||||
guest
|
guest
|
||||||
@ -1281,7 +1288,7 @@ mod tests {
|
|||||||
.trim()
|
.trim()
|
||||||
.parse::<u32>()
|
.parse::<u32>()
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
3
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
guest.ssh_command("sudo shutdown -h now")?;
|
guest.ssh_command("sudo shutdown -h now")?;
|
||||||
|
Loading…
Reference in New Issue
Block a user