diff --git a/vmm/src/config.rs b/vmm/src/config.rs index e9c0a7854..f612f8ffb 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -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 = std::result::Result; @@ -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(()) }