From 46848fdc43acc7886619839d04e218457eb0613f Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 2 Oct 2019 18:39:31 -0700 Subject: [PATCH] ci: Add integration test for virtio-iommu Simply test the guest can find the PCI device corresponding to the virtio-iommu device. Signed-off-by: Sebastien Boeuf --- src/main.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/main.rs b/src/main.rs index 9d2d72df2..2e2834af7 100755 --- a/src/main.rs +++ b/src/main.rs @@ -2742,4 +2742,56 @@ mod tests { Ok(()) }); } + + #[cfg_attr(not(feature = "mmio"), test)] + fn test_virtio_iommu() { + test_block!(tb, "", { + 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 kernel_path = workload_path.clone(); + kernel_path.push("bzImage"); + + let mut child = Command::new("target/debug/cloud-hypervisor") + .args(&["--cpus", "1"]) + .args(&["--memory", "size=512M"]) + .args(&["--kernel", kernel_path.to_str().unwrap()]) + .args(&[ + "--disk", + format!( + "path={},iommu=on", + guest.disk_config.disk(DiskType::OperatingSystem).unwrap() + ) + .as_str(), + format!( + "path={},iommu=on", + guest.disk_config.disk(DiskType::CloudInit).unwrap() + ) + .as_str(), + ]) + .args(&["--net", guest.default_net_string().as_str()]) + .args(&["--cmdline", "root=PARTUUID=19866ecd-ecc4-4ef8-b313-09a92260ef9b console=tty0 console=ttyS0,115200n8 console=hvc0 quiet init=/usr/lib/systemd/systemd-bootchart initcall_debug tsc=reliable no_timer_check noreplace-smp cryptomgr.notests rootfstype=ext4,btrfs,xfs kvm-intel.nested=1 rw"]) + .spawn() + .unwrap(); + + thread::sleep(std::time::Duration::new(20, 0)); + + #[cfg(not(feature = "mmio"))] + aver!( + tb, + guest + .does_device_vendor_pair_match("0x1057", "0x1af4") + .unwrap_or_default() + ); + + guest.ssh_command("sudo shutdown -h now")?; + thread::sleep(std::time::Duration::new(10, 0)); + let _ = child.kill(); + let _ = child.wait(); + + Ok(()) + }); + } }