mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-24 00:41:16 +00:00
vmm: device_manager: Make add_virtio_pci_device a method
Remove some in/out parameters and instead rely on them as members of the &mut self parameter. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
aaa5e2e9ea
commit
d9e1c2cd22
@ -568,14 +568,12 @@ impl DeviceManager {
|
|||||||
&None
|
&None
|
||||||
};
|
};
|
||||||
|
|
||||||
let virtio_iommu_attach_dev = DeviceManager::add_virtio_pci_device(
|
let virtio_iommu_attach_dev = self.add_virtio_pci_device(
|
||||||
device,
|
device,
|
||||||
vm_info.memory,
|
vm_info.memory,
|
||||||
&self.address_manager,
|
|
||||||
vm_info.vm_fd,
|
vm_info.vm_fd,
|
||||||
&mut pci_bus,
|
&mut pci_bus,
|
||||||
mapping,
|
mapping,
|
||||||
&mut self.migratable_devices,
|
|
||||||
interrupt_manager,
|
interrupt_manager,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -601,14 +599,12 @@ impl DeviceManager {
|
|||||||
// Because we determined the virtio-iommu b/d/f, we have to
|
// Because we determined the virtio-iommu b/d/f, we have to
|
||||||
// add the device to the PCI topology now. Otherwise, the
|
// add the device to the PCI topology now. Otherwise, the
|
||||||
// b/d/f won't match the virtio-iommu device as expected.
|
// b/d/f won't match the virtio-iommu device as expected.
|
||||||
DeviceManager::add_virtio_pci_device(
|
self.add_virtio_pci_device(
|
||||||
Arc::new(Mutex::new(iommu_device)),
|
Arc::new(Mutex::new(iommu_device)),
|
||||||
vm_info.memory,
|
vm_info.memory,
|
||||||
&self.address_manager,
|
|
||||||
vm_info.vm_fd,
|
vm_info.vm_fd,
|
||||||
&mut pci_bus,
|
&mut pci_bus,
|
||||||
&None,
|
&None,
|
||||||
&mut self.migratable_devices,
|
|
||||||
interrupt_manager,
|
interrupt_manager,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
@ -1451,13 +1447,12 @@ impl DeviceManager {
|
|||||||
#[cfg(feature = "pci_support")]
|
#[cfg(feature = "pci_support")]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn add_virtio_pci_device(
|
fn add_virtio_pci_device(
|
||||||
|
&mut self,
|
||||||
virtio_device: Arc<Mutex<dyn vm_virtio::VirtioDevice>>,
|
virtio_device: Arc<Mutex<dyn vm_virtio::VirtioDevice>>,
|
||||||
memory: &Arc<ArcSwap<GuestMemoryMmap>>,
|
memory: &Arc<ArcSwap<GuestMemoryMmap>>,
|
||||||
address_manager: &Arc<AddressManager>,
|
|
||||||
vm_fd: &Arc<VmFd>,
|
vm_fd: &Arc<VmFd>,
|
||||||
pci: &mut PciBus,
|
pci: &mut PciBus,
|
||||||
iommu_mapping: &Option<Arc<IommuMapping>>,
|
iommu_mapping: &Option<Arc<IommuMapping>>,
|
||||||
migratable_devices: &mut Vec<Arc<Mutex<dyn Migratable>>>,
|
|
||||||
interrupt_manager: &Arc<dyn InterruptManager>,
|
interrupt_manager: &Arc<dyn InterruptManager>,
|
||||||
) -> DeviceManagerResult<Option<u32>> {
|
) -> DeviceManagerResult<Option<u32>> {
|
||||||
// Allows support for one MSI-X vector per queue. It also adds 1
|
// Allows support for one MSI-X vector per queue. It also adds 1
|
||||||
@ -1501,7 +1496,7 @@ impl DeviceManager {
|
|||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::VirtioDevice)?;
|
.map_err(DeviceManagerError::VirtioDevice)?;
|
||||||
|
|
||||||
let mut allocator = address_manager.allocator.lock().unwrap();
|
let mut allocator = self.address_manager.allocator.lock().unwrap();
|
||||||
let bars = virtio_pci_device
|
let bars = virtio_pci_device
|
||||||
.allocate_bars(&mut allocator)
|
.allocate_bars(&mut allocator)
|
||||||
.map_err(DeviceManagerError::AllocateBars)?;
|
.map_err(DeviceManagerError::AllocateBars)?;
|
||||||
@ -1521,13 +1516,14 @@ impl DeviceManager {
|
|||||||
|
|
||||||
pci.register_mapping(
|
pci.register_mapping(
|
||||||
virtio_pci_device.clone(),
|
virtio_pci_device.clone(),
|
||||||
address_manager.io_bus.as_ref(),
|
self.address_manager.io_bus.as_ref(),
|
||||||
address_manager.mmio_bus.as_ref(),
|
self.address_manager.mmio_bus.as_ref(),
|
||||||
bars,
|
bars,
|
||||||
)
|
)
|
||||||
.map_err(DeviceManagerError::AddPciDevice)?;
|
.map_err(DeviceManagerError::AddPciDevice)?;
|
||||||
|
|
||||||
migratable_devices.push(Arc::clone(&virtio_pci_device) as Arc<Mutex<dyn Migratable>>);
|
self.migratable_devices
|
||||||
|
.push(Arc::clone(&virtio_pci_device) as Arc<Mutex<dyn Migratable>>);
|
||||||
|
|
||||||
let ret = if iommu_mapping.is_some() {
|
let ret = if iommu_mapping.is_some() {
|
||||||
Some(dev_id)
|
Some(dev_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user