mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vfio: Create VFIO implementation of ExternalDmaMapping
With this implementation of the trait ExternalDmaMapping, we now have the tool to provide to the virtual IOMMU to trigger the map/unmap on behalf of the guest. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
3598e603d5
commit
837bcbc6ba
@@ -36,7 +36,7 @@ use std::ptr::null_mut;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
#[cfg(feature = "pci_support")]
|
||||
use vfio::{VfioDevice, VfioPciDevice, VfioPciError};
|
||||
use vfio::{VfioDevice, VfioDmaMapping, VfioPciDevice, VfioPciError};
|
||||
use vm_allocator::SystemAllocator;
|
||||
#[cfg(feature = "mmio_support")]
|
||||
use vm_memory::GuestAddress;
|
||||
@@ -998,15 +998,18 @@ impl DeviceManager {
|
||||
// global device ID.
|
||||
let device_id = pci.next_device_id() << 3;
|
||||
|
||||
if device_cfg.iommu {
|
||||
iommu_attached_list.push(device_id);
|
||||
}
|
||||
|
||||
let vfio_device =
|
||||
VfioDevice::new(&device_cfg.path, device_fd.clone(), vm_info.memory.clone())
|
||||
.map_err(DeviceManagerError::VfioCreate)?;
|
||||
|
||||
let _vfio_container = vfio_device.get_container();
|
||||
if device_cfg.iommu {
|
||||
let _vfio_mapping = VfioDmaMapping::new(
|
||||
vfio_device.get_container(),
|
||||
Arc::clone(vm_info.memory),
|
||||
);
|
||||
|
||||
iommu_attached_list.push(device_id);
|
||||
}
|
||||
|
||||
let mut vfio_pci_device = VfioPciDevice::new(vm_info.vm_fd, allocator, vfio_device)
|
||||
.map_err(DeviceManagerError::VfioPciCreate)?;
|
||||
|
||||
Reference in New Issue
Block a user