mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
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:
parent
cb220ae184
commit
5109f914eb
@ -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(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user