From 09829c44b2b742839304ac592f63b1b51b321bb9 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 4 Mar 2020 16:27:58 +0100 Subject: [PATCH] vmm: Remove IO bus strong reference from Vm The Vm structure was used to store a strong reference to the IO bus. This is not needed anymore since the AddressManager is logically the one holding this strong reference. This has been made possible by the introduction of Weak references on the Bus structure itself. Signed-off-by: Sebastien Boeuf --- vmm/src/device_manager.rs | 3 +-- vmm/src/vm.rs | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index d8f1c84a1..105613018 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -474,7 +474,6 @@ impl DeviceManager { _exit_evt: &EventFd, reset_evt: &EventFd, vmm_path: PathBuf, - io_bus: &Arc, ) -> DeviceManagerResult>> { let mut virtio_devices: Vec<(Arc>, bool)> = Vec::new(); let migratable_devices: Vec>> = Vec::new(); @@ -486,7 +485,7 @@ impl DeviceManager { let address_manager = Arc::new(AddressManager { allocator, - io_bus: Arc::clone(io_bus), + io_bus: Arc::new(devices::Bus::new()), mmio_bus: Arc::new(devices::Bus::new()), vm_fd: vm_fd.clone(), }); diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index e919f1d14..7d7daea59 100755 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -222,8 +222,6 @@ pub struct Vm { state: RwLock, cpu_manager: Arc>, memory_manager: Arc>, - // Hold the strong reference onto the IO bus. - _io_bus: Arc, } impl Vm { @@ -331,8 +329,6 @@ impl Vm { .ok_or(Error::CreateSystemAllocator)?, )); - let io_bus = Arc::new(devices::Bus::new()); - let memory_config = config.lock().unwrap().memory.clone(); let memory_manager = MemoryManager::new( @@ -355,7 +351,6 @@ impl Vm { &exit_evt, &reset_evt, vmm_path, - &io_bus, ) .map_err(Error::DeviceManager)?; @@ -384,7 +379,6 @@ impl Vm { state: RwLock::new(VmState::Created), cpu_manager, memory_manager, - _io_bus: io_bus, }) }