From 02adc4061aa2e61b2a88f082c74ca5483a10a2a6 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 27 Feb 2020 17:44:14 +0100 Subject: [PATCH] vmm: Store PciBus from DeviceManager Helps with future refactoring of VFIO device creation. Signed-off-by: Sebastien Boeuf --- vmm/src/device_manager.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index a9beb6ad3..0b391467e 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -429,6 +429,10 @@ pub struct DeviceManager { // Backends that have been spawned vhost_user_backends: Vec, + + // Keep a reference to the PCI bus + #[cfg(feature = "pci_support")] + pci_bus: Option>>, } impl DeviceManager { @@ -515,6 +519,8 @@ impl DeviceManager { virtio_devices: Vec::new(), vmm_path, vhost_user_backends: Vec::new(), + #[cfg(feature = "pci_support")] + pci_bus: None, }; device_manager @@ -625,12 +631,12 @@ impl DeviceManager { } let pci_bus = Arc::new(Mutex::new(pci_bus)); - let pci_config_io = Arc::new(Mutex::new(PciConfigIo::new(pci_bus.clone()))); + let pci_config_io = Arc::new(Mutex::new(PciConfigIo::new(Arc::clone(&pci_bus)))); self.address_manager .io_bus .insert(pci_config_io, 0xcf8, 0x8) .map_err(DeviceManagerError::BusError)?; - let pci_config_mmio = Arc::new(Mutex::new(PciConfigMmio::new(pci_bus))); + let pci_config_mmio = Arc::new(Mutex::new(PciConfigMmio::new(Arc::clone(&pci_bus)))); self.address_manager .mmio_bus .insert( @@ -639,6 +645,8 @@ impl DeviceManager { arch::layout::PCI_MMCONFIG_SIZE, ) .map_err(DeviceManagerError::BusError)?; + + self.pci_bus = Some(pci_bus); } Ok(())