From e3d6e222a1d2ccccffa09e5b2eee9e2a671ed3fc Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 11 Oct 2021 15:55:35 +0100 Subject: [PATCH] vmm: Add the required number of PCI segments The platform config may specify a number of PCI segments to use, if this greater than 1 then we add supplemental PCI segments as well as the default segment. Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index c959c82cb..ba3c6fc51 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -948,6 +948,23 @@ impl DeviceManager { let start_of_device_area = memory_manager.lock().unwrap().start_of_device_area().0; let end_of_device_area = memory_manager.lock().unwrap().end_of_device_area().0; + let mut pci_segments = vec![PciSegment::new_default_segment( + &address_manager, + start_of_device_area, + end_of_device_area, + )?]; + + if let Some(platform_config) = config.lock().unwrap().platform.as_ref() { + for i in 1..platform_config.num_pci_segments { + pci_segments.push(PciSegment::new( + i as u16, + &address_manager, + start_of_device_area, + end_of_device_area, + )?); + } + } + let device_manager = DeviceManager { address_manager: Arc::clone(&address_manager), console: Arc::new(Console::default()), @@ -966,11 +983,7 @@ impl DeviceManager { vfio_container: None, iommu_device: None, iommu_attached_devices: None, - pci_segments: vec![PciSegment::new_default_segment( - &address_manager, - start_of_device_area, - end_of_device_area, - )?], + pci_segments, device_tree, exit_evt: exit_evt.try_clone().map_err(DeviceManagerError::EventFd)?, reset_evt: reset_evt.try_clone().map_err(DeviceManagerError::EventFd)?,