vfio: Don't map guest memory for VFIO devices attached to vIOMMU

In case a VFIO devices is being attached behind a virtual IOMMU, we
should not automatically map the entire guest memory for the specific
device.

A VFIO device attached to the virtual IOMMU will be driven with IOVAs,
hence we should simply wait for the requests coming from the virtual
IOMMU.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-10-08 12:50:05 -07:00
committed by Samuel Ortiz
parent 63c30a6e79
commit 3acf9dfcf3
2 changed files with 24 additions and 13 deletions

View File

@@ -999,9 +999,13 @@ impl DeviceManager {
// global device ID.
let device_id = pci.next_device_id() << 3;
let vfio_device =
VfioDevice::new(&device_cfg.path, device_fd.clone(), vm_info.memory.clone())
.map_err(DeviceManagerError::VfioCreate)?;
let vfio_device = VfioDevice::new(
&device_cfg.path,
device_fd.clone(),
vm_info.memory.clone(),
device_cfg.iommu,
)
.map_err(DeviceManagerError::VfioCreate)?;
if device_cfg.iommu {
if let Some(iommu) = iommu_device {