From d2080fd2210bb947c46481774ffeedcc0ff915c0 Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Tue, 2 Jan 2024 14:19:15 +0800 Subject: [PATCH] runtime-rs: refactor getting the vfio device guest pci path Fixes: #8748 Signed-off-by: alex.lyn --- .../crates/hypervisor/src/dragonball/inner_device.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs index 3cf3ce8941..48df4247c8 100644 --- a/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs +++ b/src/runtime-rs/crates/hypervisor/src/dragonball/inner_device.rs @@ -137,13 +137,10 @@ impl DragonballInner { 0 }; - let guest_dev_id = if let Some(pci_path) = primary_device.guest_pci_path { - // safe here, dragonball's pci device directly connects to root bus. - // usually, it has been assigned in vfio device manager. - pci_path.get_device_slot().unwrap().0 - } else { - 0 - }; + // It's safe to unwrap the guest_pci_path and get device slot, + // As it has been assigned in vfio device manager. + let pci_path = primary_device.guest_pci_path.unwrap(); + let guest_dev_id = pci_path.get_device_slot().unwrap().0; info!( sl!(),