From e8b6fe054859b3631ec030330a4999a3d9ef4d9c Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Sat, 11 Apr 2026 04:51:22 +0000 Subject: [PATCH] tests: vfio: Capture guest dmesg when nvidia-smi failed The guest dmesg can provide more context from the guest kernel, say Nvidia driver errors, IOMMU faults, etc. Signed-off-by: Bo Chen --- test_infra/src/lib.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 248e4efa3..47d022cd6 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -1316,11 +1316,18 @@ impl Guest { #[cfg(target_arch = "x86_64")] pub fn check_nvidia_gpu(&self) { - assert!( - self.ssh_command("nvidia-smi") - .unwrap() - .contains("NVIDIA L40S") - ); + let output = self.ssh_command("nvidia-smi").unwrap(); + if !output.contains("NVIDIA L40S") { + let dmesg = self + .ssh_command("sudo dmesg") + .unwrap_or_else(|e| format!("Failed to get dmesg: {e:?}")); + eprintln!( + "\n\n==== Guest dmesg (nvidia-smi check failed) ====\n\n\ + {dmesg}\n\ + \n==== End guest dmesg ====\n\n" + ); + panic!("nvidia-smi output did not contain 'NVIDIA L40S': {output}"); + } } pub fn reboot_linux(&self, current_reboot_count: u32) {