mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Introduce PciDeviceCommonConfig::validate()
Implement some common PCI segment validation. This can be used to reduce duplication across the different validation methods. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -1226,6 +1226,23 @@ impl PciDeviceCommonConfig {
|
||||
pci_segment,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn validate(&self, vm_config: &VmConfig) -> ValidationResult<()> {
|
||||
if let Some(platform_config) = vm_config.platform.as_ref() {
|
||||
if self.pci_segment >= platform_config.num_pci_segments {
|
||||
return Err(ValidationError::InvalidPciSegment(self.pci_segment));
|
||||
}
|
||||
|
||||
if let Some(iommu_segments) = platform_config.iommu_segments.as_ref()
|
||||
&& iommu_segments.contains(&self.pci_segment)
|
||||
&& !self.iommu
|
||||
{
|
||||
return Err(ValidationError::OnIommuSegment(self.pci_segment));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl DiskConfig {
|
||||
|
||||
Reference in New Issue
Block a user