From fb185fa839382b50012fba167311e25aec3a1833 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 18 Mar 2020 17:24:35 +0000 Subject: [PATCH] vmm: Always return PCI B/D/F from add_virtio_pci_device Previously this was only returned if the device had an IOMMU mapping and whether the device should be added to the virtio-iommu. This was already captured earlier as part of creating the device so use that information instead. Always returning the B/D/F is helpful as it facilitates virtio PCI device hotplug. Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 9b9e731f6..068bcf268 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -715,10 +715,10 @@ impl DeviceManager { &None }; - let virtio_iommu_attach_dev = + let dev_id = self.add_virtio_pci_device(device, &mut pci_bus, mapping, &interrupt_manager)?; - if let Some(dev_id) = virtio_iommu_attach_dev { + if iommu_attached { iommu_attached_devices.push(dev_id); } } @@ -1631,7 +1631,7 @@ impl DeviceManager { pci: &mut PciBus, iommu_mapping: &Option>, interrupt_manager: &Arc>, - ) -> DeviceManagerResult> { + ) -> DeviceManagerResult { // Allows support for one MSI-X vector per queue. It also adds 1 // as we need to take into account the dedicated vector to notify // about a virtio config change. @@ -1710,13 +1710,7 @@ impl DeviceManager { self.migratable_devices .push(Arc::clone(&virtio_pci_device) as Arc>); - let ret = if iommu_mapping.is_some() { - Some(pci_device_bdf) - } else { - None - }; - - Ok(ret) + Ok(pci_device_bdf) } #[cfg(feature = "mmio_support")]