| 802 | } |
| 803 | |
| 804 | pub fn validate(&self, vm_config: &VmConfig) -> ValidationResult<()> { |
| 805 | let num_pci_segments = match &vm_config.platform { |
| 806 | Some(platform_config) => platform_config.num_pci_segments, |
| 807 | None => 1, |
| 808 | }; |
| 809 | |
| 810 | if self.pci_segment >= num_pci_segments { |
| 811 | return Err(ValidationError::InvalidPciSegment(self.pci_segment)); |
| 812 | } |
| 813 | |
| 814 | if self.mmio32_aperture_weight == 0 { |
| 815 | return Err(ValidationError::InvalidPciSegmentApertureWeight( |
| 816 | self.mmio32_aperture_weight, |
| 817 | )); |
| 818 | } |
| 819 | |
| 820 | if self.mmio64_aperture_weight == 0 { |
| 821 | return Err(ValidationError::InvalidPciSegmentApertureWeight( |
| 822 | self.mmio64_aperture_weight, |
| 823 | )); |
| 824 | } |
| 825 | |
| 826 | Ok(()) |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | impl PlatformConfig { |