pci, vmm: Switch to use more generic VfioOps trait

Replace the concrete `VfioContainer` type with the `VfioOps` trait
object for device passthrough. This decouples the VFIO DMA mapping
interface from the legacy VFIO container/group implementation, allowing
it to be extended to support VFIO cdev and iommufd in the future.

Signed-off-by: Bo Chen <bchen@crusoe.ai>
This commit is contained in:
Bo Chen
2025-05-21 21:02:56 +00:00
parent 5bb4ea20a5
commit 7360bfe33a
2 changed files with 7 additions and 9 deletions

View File

@@ -1032,7 +1032,7 @@ pub struct DeviceManager {
// VFIO container
// Only one container can be created, therefore it is stored as part of the
// DeviceManager to be reused.
vfio_container: Option<Arc<VfioContainer>>,
vfio_container: Option<Arc<dyn VfioOps>>,
// Paravirtualized IOMMU
iommu_device: Option<Arc<Mutex<virtio_devices::Iommu>>>,
@@ -3798,7 +3798,7 @@ impl DeviceManager {
self.add_vfio_device(device_cfg)
}
fn create_vfio_container(&self) -> DeviceManagerResult<Arc<VfioContainer>> {
fn create_vfio_container(&self) -> DeviceManagerResult<Arc<dyn VfioOps>> {
let passthrough_device = self
.passthrough_device
.as_ref()