From 548f252bc4710dbc9675cda9fc45a67db80cb49c Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Mon, 8 Jan 2024 15:30:48 +0800 Subject: [PATCH] runtime-rs: bugfix incorrect use of refcount before vfio attach When there's a pod with multiple containers, there may be case that attach point more than 2, we should not return Err in that case when we are doing attach ops, but just return Ok. Fixes: #8738 Signed-off-by: Alex Lyn --- .../crates/hypervisor/src/device/driver/vfio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs index 7d8abd2e09..578e5d35c2 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs @@ -456,7 +456,13 @@ impl Device for VfioDevice { .await .context("failed to increase attach count")? { - return Err(anyhow!("attach count increased failed as some reason.")); + warn!( + sl!(), + "The device {:?} is not allowed to be attached more than one times.", + self.device_id + ); + + return Ok(()); } // do add device for vfio deivce