vmm: config: Reject attempts to use VFIO or IOMMU without PCI

Generate an error during validation if an attempt it made to place a
device behind an IOMMU or using a VFIO device when not using PCI.

Fixes: #751

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-05-05 09:59:49 +01:00
parent cb220ae184
commit 5109f914eb

View File

@ -84,6 +84,10 @@ pub enum ValidationError {
DiskSocketAndPath,
/// Using vhost user requires shared memory
VhostUserRequiresSharedMemory,
/// Trying to use IOMMU without PCI
IommuUnsupported,
/// Trying to use VFIO without PCI
VfioUnsupported,
}
type ValidationResult<T> = std::result::Result<T, ValidationError>;
@ -100,6 +104,8 @@ impl fmt::Display for ValidationError {
VhostUserRequiresSharedMemory => {
write!(f, "Using vhost-user requires using shared memory")
}
IommuUnsupported => write!(f, "Using an IOMMU without PCI support is unsupported"),
VfioUnsupported => write!(f, "Using VFIO without PCI support is unsupported"),
}
}
}
@ -1293,6 +1299,15 @@ impl VmConfig {
}
}
if cfg!(not(feature = "pci_support")) {
if self.iommu {
return Err(ValidationError::IommuUnsupported);
}
if self.devices.is_some() {
return Err(ValidationError::VfioUnsupported);
}
}
Ok(())
}