The VFIO integration test starts cloud-hypervisor guest with 3 TAP backed networking interfaces, bound through a simple bridge on the host. So if the nested cloud-hypervisor succeeds in getting a directly assigned interface from its cloud-hypervisor host, we should be able to ssh into it, and verify that it's running with the right kernel command line (We tag the command line from cloud-hypervisor
()
| 2342 | // Also, we pass-through a virtio-blk device to the L2 VM to test the 32-bit |
| 2343 | // vfio device support |
| 2344 | fn test_vfio() { |
| 2345 | setup_vfio_network_interfaces(); |
| 2346 | |
| 2347 | let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string()); |
| 2348 | let guest = Guest::new_from_ip_range(Box::new(disk_config), "172.18", 0); |
| 2349 | |
| 2350 | let mut workload_path = dirs::home_dir().unwrap(); |
| 2351 | workload_path.push("workloads"); |
| 2352 | |
| 2353 | let kernel_path = direct_kernel_boot_path(); |
| 2354 | |
| 2355 | let mut vfio_path = workload_path.clone(); |
| 2356 | vfio_path.push("vfio"); |
| 2357 | |
| 2358 | let mut cloud_init_vfio_base_path = vfio_path.clone(); |
| 2359 | cloud_init_vfio_base_path.push("cloudinit.img"); |
| 2360 | |
| 2361 | // Prepare a separate cloud-init for the L2 guest with its own |
| 2362 | // boot notification port. |
| 2363 | let (_l2_ci_dir, l2_ci_path) = guest.prepare_l2_cloudinit(); |
| 2364 | rate_limited_copy(l2_ci_path, &cloud_init_vfio_base_path) |
| 2365 | .expect("copying of L2 cloud-init disk failed"); |
| 2366 | |
| 2367 | let mut vfio_disk_path = workload_path.clone(); |
| 2368 | vfio_disk_path.push("vfio.img"); |
| 2369 | |
| 2370 | // Create the vfio disk image |
| 2371 | let output = Command::new("mkfs.ext4") |
| 2372 | .arg("-d") |
| 2373 | .arg(vfio_path.to_str().unwrap()) |
| 2374 | .arg(vfio_disk_path.to_str().unwrap()) |
| 2375 | .arg("2g") |
| 2376 | .output() |
| 2377 | .unwrap(); |
| 2378 | if !output.status.success() { |
| 2379 | eprintln!("{}", String::from_utf8_lossy(&output.stderr)); |
| 2380 | panic!("mkfs.ext4 command generated an error"); |
| 2381 | } |
| 2382 | |
| 2383 | let mut blk_file_path = workload_path; |
| 2384 | blk_file_path.push("blk.img"); |
| 2385 | |
| 2386 | let vfio_tap0 = "vfio-tap0"; |
| 2387 | let vfio_tap1 = "vfio-tap1"; |
| 2388 | let vfio_tap2 = "vfio-tap2"; |
| 2389 | let vfio_tap3 = "vfio-tap3"; |
| 2390 | |
| 2391 | let mut child = GuestCommand::new(&guest) |
| 2392 | .args(["--cpus", "boot=4"]) |
| 2393 | .args(["--memory", "size=2G,hugepages=on,shared=on"]) |
| 2394 | .args(["--kernel", kernel_path.to_str().unwrap()]) |
| 2395 | .args([ |
| 2396 | "--disk", |
| 2397 | format!( |
| 2398 | "path={}", |
| 2399 | guest.disk_config.disk(DiskType::OperatingSystem).unwrap() |
| 2400 | ) |
| 2401 | .as_str(), |
nothing calls this directly
no test coverage detected