From a93dbe790ff49d99b0a5427ecb54f092bbccff11 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 4 May 2026 15:05:28 +0100 Subject: [PATCH] tests: Cleanup interfaces in test_vfio If this test flakes is can then cause subsequent invocations to fail as the test has left its special test interfaces alive. Signed-off-by: Rob Bradford --- cloud-hypervisor/tests/common/utils.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cloud-hypervisor/tests/common/utils.rs b/cloud-hypervisor/tests/common/utils.rs index a76878f7a..48d8441c1 100644 --- a/cloud-hypervisor/tests/common/utils.rs +++ b/cloud-hypervisor/tests/common/utils.rs @@ -757,6 +757,9 @@ pub(crate) fn get_pty_path(api_socket: &str, pty_type: &str) -> PathBuf { // We reserve a different IP class for it: 172.18.0.0/24. #[cfg(target_arch = "x86_64")] pub(crate) fn setup_vfio_network_interfaces() { + // Clean up any leftover interfaces from previous runs + cleanup_vfio_network_interfaces(); + // 'vfio-br0' assert!(exec_host_command_status("sudo ip link add name vfio-br0 type bridge").success()); assert!(exec_host_command_status("sudo ip link set vfio-br0 up").success()); @@ -782,11 +785,11 @@ pub(crate) fn setup_vfio_network_interfaces() { // Tear VFIO test network down #[cfg(target_arch = "x86_64")] pub(crate) fn cleanup_vfio_network_interfaces() { - assert!(exec_host_command_status("sudo ip link del vfio-br0").success()); - assert!(exec_host_command_status("sudo ip link del vfio-tap0").success()); - assert!(exec_host_command_status("sudo ip link del vfio-tap1").success()); - assert!(exec_host_command_status("sudo ip link del vfio-tap2").success()); - assert!(exec_host_command_status("sudo ip link del vfio-tap3").success()); + let _ = exec_host_command_status("sudo ip link del vfio-br0"); + let _ = exec_host_command_status("sudo ip link del vfio-tap0"); + let _ = exec_host_command_status("sudo ip link del vfio-tap1"); + let _ = exec_host_command_status("sudo ip link del vfio-tap2"); + let _ = exec_host_command_status("sudo ip link del vfio-tap3"); } pub(crate) fn balloon_size(api_socket: &str) -> u64 {