diff --git a/devices/src/ivshmem.rs b/devices/src/ivshmem.rs index fff48a72c..98291c74e 100644 --- a/devices/src/ivshmem.rs +++ b/devices/src/ivshmem.rs @@ -217,7 +217,7 @@ impl BusDevice for IvshmemDevice { impl PciDevice for IvshmemDevice { fn allocate_bars( &mut self, - _allocator: &Arc>, + _allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/devices/src/pvmemcontrol.rs b/devices/src/pvmemcontrol.rs index 06e0e2492..d4b37456b 100644 --- a/devices/src/pvmemcontrol.rs +++ b/devices/src/pvmemcontrol.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use std::ffi::CString; -use std::sync::{Arc, Barrier, Mutex, RwLock}; +use std::sync::{Arc, Barrier, RwLock}; use std::{io, result}; use log::{debug, warn}; @@ -722,7 +722,7 @@ impl PciDevice for PvmemcontrolPciDevice { fn allocate_bars( &mut self, - _allocator: &Arc>, + _allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, _mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/devices/src/pvpanic.rs b/devices/src/pvpanic.rs index 0451da1a0..9540a9125 100644 --- a/devices/src/pvpanic.rs +++ b/devices/src/pvpanic.rs @@ -5,7 +5,7 @@ use std::any::Any; use std::result; -use std::sync::{Arc, Barrier, Mutex}; +use std::sync::{Arc, Barrier}; use anyhow::anyhow; use event_monitor::event; @@ -174,7 +174,7 @@ impl PciDevice for PvPanicDevice { fn allocate_bars( &mut self, - _allocator: &Arc>, + _allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, _mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/pci/src/device.rs b/pci/src/device.rs index 3a23ea777..29c89b8c4 100644 --- a/pci/src/device.rs +++ b/pci/src/device.rs @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use std::any::Any; -use std::sync::{Arc, Barrier, Mutex}; +use std::sync::{Arc, Barrier}; use std::{io, result}; use serde::{Deserialize, Serialize}; @@ -49,7 +49,7 @@ pub trait PciDevice: Send { /// returns an address. Returns a Vec of (GuestAddress, GuestUsize) tuples. fn allocate_bars( &mut self, - _allocator: &Arc>, + _allocator: &mut SystemAllocator, _mmio32_allocator: &mut AddressAllocator, _mmio64_allocator: &mut AddressAllocator, _resources: Option>, diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index f1d22ff63..53c77a95c 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -602,7 +602,7 @@ impl VfioCommon { #[allow(unused_variables)] pub(crate) fn allocate_bars( &mut self, - allocator: &Arc>, + allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, mmio64_allocator: &mut AddressAllocator, resources: Option<&[Resource]>, @@ -741,8 +741,6 @@ impl VfioCommon { PciBarRegionType::IoRegion => { // The address needs to be 4 bytes aligned. allocator - .lock() - .unwrap() .allocate_io_addresses(restored_bar_addr, region_size, Some(0x4)) .ok_or(PciDeviceError::IoAllocationFailed(region_size))? } @@ -1852,7 +1850,7 @@ const PCI_ROM_EXP_BAR_INDEX: usize = 12; impl PciDevice for VfioPciDevice { fn allocate_bars( &mut self, - allocator: &Arc>, + allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/pci/src/vfio_user.rs b/pci/src/vfio_user.rs index 248f87272..456047d42 100644 --- a/pci/src/vfio_user.rs +++ b/pci/src/vfio_user.rs @@ -391,7 +391,7 @@ impl Vfio for VfioUserClientWrapper { impl PciDevice for VfioUserPciDevice { fn allocate_bars( &mut self, - allocator: &Arc>, + allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index dd54472d3..36975e3f7 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -978,7 +978,7 @@ impl PciDevice for VirtioPciDevice { fn allocate_bars( &mut self, - _allocator: &Arc>, + _allocator: &mut SystemAllocator, mmio32_allocator: &mut AddressAllocator, mmio64_allocator: &mut AddressAllocator, resources: Option>, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index b6d35964f..edb8b76af 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -3995,7 +3995,7 @@ impl DeviceManager { .lock() .unwrap() .allocate_bars( - &self.address_manager.allocator, + &mut self.address_manager.allocator.lock().unwrap(), &mut self.pci_segments[segment_id as usize] .mem32_allocator .lock()