mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Break the cyclic dependency between DeviceManager and IO bus
By inserting the DeviceManager on the IO bus, we introduced some cyclic
dependency:
DeviceManager ---> AddressManager ---> Bus ---> BusDevice
^ |
| |
+---------------------------------------------+
This cycle needs to be broken by inserting a Weak reference instead of
an Arc (considered as a strong reference).
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
c1af13efeb
commit
d47f733e51
@@ -222,6 +222,8 @@ pub struct Vm {
|
||||
state: RwLock<VmState>,
|
||||
cpu_manager: Arc<Mutex<cpu::CpuManager>>,
|
||||
memory_manager: Arc<Mutex<MemoryManager>>,
|
||||
// Hold the strong reference onto the IO bus.
|
||||
_io_bus: Arc<devices::Bus>,
|
||||
}
|
||||
|
||||
impl Vm {
|
||||
@@ -329,6 +331,8 @@ 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(
|
||||
@@ -351,6 +355,7 @@ impl Vm {
|
||||
&exit_evt,
|
||||
&reset_evt,
|
||||
vmm_path,
|
||||
&io_bus,
|
||||
)
|
||||
.map_err(Error::DeviceManager)?;
|
||||
|
||||
@@ -379,6 +384,7 @@ impl Vm {
|
||||
state: RwLock::new(VmState::Created),
|
||||
cpu_manager,
|
||||
memory_manager,
|
||||
_io_bus: io_bus,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user