vmm: Move DeviceManager into an Arc<Mutex<>>

In anticipation of the support for device hotplug, this commit moves the
DeviceManager object into an Arc<Mutex<>> when the DeviceManager is
being created. The reason is, we need the DeviceManager to implement the
BusDevice trait and then provide it to the IO bus, so that IO accesses
related to device hotplug can be handled correctly.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-02-27 10:29:03 +01:00
parent 531f4ff6b0
commit 8142c823ed
4 changed files with 20 additions and 13 deletions

View File

@@ -494,7 +494,7 @@ impl CpuManager {
pub fn new(
boot_vcpus: u8,
max_vcpus: u8,
device_manager: &DeviceManager,
device_manager: &Arc<Mutex<DeviceManager>>,
guest_memory: GuestMemoryAtomic<GuestMemoryMmap>,
fd: Arc<VmFd>,
cpuid: CpuId,
@@ -503,6 +503,7 @@ impl CpuManager {
let mut vcpu_states = Vec::with_capacity(usize::from(max_vcpus));
vcpu_states.resize_with(usize::from(max_vcpus), VcpuState::default);
let device_manager = device_manager.lock().unwrap();
let cpu_manager = Arc::new(Mutex::new(CpuManager {
boot_vcpus,
max_vcpus,