From ac01ceddbbaac91bc7977a1ec5d261f274da15b7 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 29 Jan 2020 18:47:46 +0100 Subject: [PATCH] vmm: Cleanup list of PCI IDs related to virtual IOMMU Now that devices attached to the virtual IOMMU are described through virtio configuration, there is no need for the DeviceManager to store the list of IDs for all these devices. Instead, things are handled locally when PCI devices are being added. Signed-off-by: Sebastien Boeuf --- vmm/src/device_manager.rs | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index b776d7486..9925a6ae9 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -384,10 +384,6 @@ pub struct DeviceManager { // Things to be added to the commandline (i.e. for virtio-mmio) cmdline_additions: Vec, - // Virtual IOMMU ID along with the list of device IDs attached to the - // virtual IOMMU. This is useful for filling the ACPI IORT table. - virt_iommu: Option<(u32, Vec)>, - // ACPI GED notification device #[cfg(feature = "acpi")] ged_notification_device: Option>>, @@ -422,9 +418,6 @@ impl DeviceManager { #[allow(unused_mut)] let mut cmdline_additions = Vec::new(); - #[allow(unused_mut)] - let mut virt_iommu: Option<(u32, Vec)> = None; - let address_manager = Arc::new(AddressManager { allocator, io_bus: Arc::new(io_bus), @@ -509,7 +502,6 @@ impl DeviceManager { vm_info, &address_manager, &memory_manager, - &mut virt_iommu, virtio_devices, &interrupt_manager, &mut migratable_devices, @@ -548,7 +540,6 @@ impl DeviceManager { ioapic: Some(ioapic), _mmap_regions, cmdline_additions, - virt_iommu, #[cfg(feature = "acpi")] ged_notification_device, #[cfg(feature = "acpi")] @@ -564,7 +555,6 @@ impl DeviceManager { vm_info: &VmInfo, address_manager: &Arc, memory_manager: &Arc>, - virt_iommu: &mut Option<(u32, Vec)>, virtio_devices: Vec<(Arc>, bool)>, interrupt_manager: &Arc, migratable_devices: &mut Vec>>, @@ -622,14 +612,7 @@ impl DeviceManager { iommu_attached_devices.append(&mut vfio_iommu_device_ids); if let Some(mut iommu_device) = iommu_device { - iommu_device.attach_pci_devices(0, iommu_attached_devices.clone()); - - // We need to shift the device id since the 3 first bits - // are dedicated to the PCI function, and we know we don't - // do multifunction. Also, because we only support one PCI - // bus, the bus 0, we don't need to add anything to the - // global device ID. - let iommu_id = pci_bus.next_device_id() << 3; + iommu_device.attach_pci_devices(0, iommu_attached_devices); // Because we determined the virtio-iommu b/d/f, we have to // add the device to the PCI topology now. Otherwise, the @@ -644,8 +627,6 @@ impl DeviceManager { migratable_devices, interrupt_manager, )?; - - *virt_iommu = Some((iommu_id, iommu_attached_devices)); } let pci_bus = Arc::new(Mutex::new(pci_bus)); @@ -1654,14 +1635,6 @@ impl DeviceManager { self.cmdline_additions.as_slice() } - pub fn virt_iommu(&self) -> Option<(u32, &[u32])> { - if let Some((iommu_id, dev_ids)) = self.virt_iommu.as_ref() { - Some((*iommu_id, dev_ids.as_slice())) - } else { - None - } - } - pub fn notify_hotplug( &self, _notification_type: HotPlugNotificationFlags,