pci: Remove all Weak references from PciBus

Now that the BusDevice devices are stored as Weak references by the IO
and MMIO buses, there's no need to use Weak references from the PciBus
anymore.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-03-04 16:10:11 +01:00
parent ca426cfdf4
commit 49268bff3b
2 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ use devices::BusDevice;
use std;
use std::any::Any;
use std::ops::DerefMut;
use std::sync::{Arc, Mutex, Weak};
use std::sync::{Arc, Mutex};
use vm_memory::{Address, GuestAddress, GuestUsize};
const VENDOR_ID_INTEL: u16 = 0x8086;
@ -80,11 +80,11 @@ pub struct PciBus {
/// Devices attached to this bus.
/// Device 0 is host bridge.
devices: Vec<Arc<Mutex<dyn PciDevice>>>,
device_reloc: Weak<dyn DeviceRelocation>,
device_reloc: Arc<dyn DeviceRelocation>,
}
impl PciBus {
pub fn new(pci_root: PciRoot, device_reloc: Weak<dyn DeviceRelocation>) -> Self {
pub fn new(pci_root: PciRoot, device_reloc: Arc<dyn DeviceRelocation>) -> Self {
let mut devices: Vec<Arc<Mutex<dyn PciDevice>>> = Vec::new();
devices.push(Arc::new(Mutex::new(pci_root)));
@ -197,7 +197,7 @@ impl PciConfigIo {
// Find out if one of the device's BAR is being reprogrammed, and
// reprogram it if needed.
if let Some(params) = device.detect_bar_reprogramming(register, data) {
if let Err(e) = pci_bus.device_reloc.upgrade().unwrap().move_bar(
if let Err(e) = pci_bus.device_reloc.move_bar(
params.old_base,
params.new_base,
params.len,
@ -313,7 +313,7 @@ impl PciConfigMmio {
// Find out if one of the device's BAR is being reprogrammed, and
// reprogram it if needed.
if let Some(params) = device.detect_bar_reprogramming(register, data) {
if let Err(e) = pci_bus.device_reloc.upgrade().unwrap().move_bar(
if let Err(e) = pci_bus.device_reloc.move_bar(
params.old_base,
params.new_base,
params.len,

View File

@ -630,7 +630,7 @@ impl DeviceManager {
let pci_root = PciRoot::new(None);
let mut pci_bus = PciBus::new(
pci_root,
Arc::downgrade(&self.address_manager) as Weak<dyn DeviceRelocation>,
Arc::clone(&self.address_manager) as Arc<dyn DeviceRelocation>,
);
let (iommu_device, iommu_mapping) = if self.config.lock().unwrap().iommu {