From f1796fe9ba1129d903bf815e1571a9e24ce95c3f Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Tue, 20 May 2025 10:30:57 +0800 Subject: [PATCH] runtime-rs: Add more fields in VfioDevice to express vfio devices To support port devices for vfio devices, more fields need to be introduced to help pass port type, bus and other information. Fixes #10361 Signed-off-by: alex.lyn --- .../crates/hypervisor/src/device/driver/vfio.rs | 14 +++++++++++++- 1 file changed, 13 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 d0f3b5ea12..c3834878e9 100644 --- a/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs +++ b/src/runtime-rs/crates/hypervisor/src/device/driver/vfio.rs @@ -20,7 +20,7 @@ use kata_sys_util::fs::get_base_name; use crate::{ device::{ pci_path::PciPath, - topology::{do_add_pcie_endpoint, PCIeTopology}, + topology::{do_add_pcie_endpoint, PCIePort, PCIeTopology}, util::{do_decrease_count, do_increase_count}, Device, DeviceType, PCIeDevice, }, @@ -223,6 +223,15 @@ pub struct VfioDevice { pub devices: Vec, // options for vfio pci handler in kata-agent pub device_options: Vec, + + // specifies the PCIe port type to which the device is attached + pub port: PCIePort, + + // bus of VFIO PCIe device + pub bus: String, + + // Indicated host device allocated or not. + pub allocated: bool, } impl VfioDevice { @@ -245,6 +254,8 @@ impl VfioDevice { config: dev_info.clone(), devices, device_options, + allocated: false, + ..Default::default() }; vfio_device @@ -480,6 +491,7 @@ impl Device for VfioDevice { if let DeviceType::Vfio(vfio) = dev { self.config = vfio.config; self.devices = vfio.devices; + self.allocated = true; } update_pcie_device!(self, pcie_topo)?;