diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 8be83b89a..8ae7c5fa7 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -413,25 +413,6 @@ impl DeviceManager { let io_bus = devices::Bus::new(); let mmio_bus = devices::Bus::new(); - let ioapic = if userspace_ioapic { - // Create IOAPIC - let ioapic = Arc::new(Mutex::new(ioapic::Ioapic::new( - vm_info.vm_fd.clone(), - APIC_START, - ))); - mmio_bus - .insert(ioapic.clone(), IOAPIC_START.0, IOAPIC_SIZE) - .map_err(DeviceManagerError::BusError)?; - Some(ioapic) - } else { - None - }; - - let interrupt_info = InterruptInfo { - _msi_capable, - ioapic: &ioapic, - }; - let mut virtio_devices: Vec<(Box, bool)> = Vec::new(); let mut mmap_regions = Vec::new(); @@ -449,6 +430,12 @@ impl DeviceManager { vm_fd: vm_info.vm_fd.clone(), }); + let ioapic = DeviceManager::make_ioapic(vm_info, &address_manager, userspace_ioapic)?; + let interrupt_info = InterruptInfo { + _msi_capable, + ioapic: &ioapic, + }; + let console = DeviceManager::make_console_device( vm_info, &address_manager, @@ -602,6 +589,30 @@ impl DeviceManager { }) } + fn make_ioapic( + vm_info: &VmInfo, + address_manager: &Arc, + userspace_ioapic: bool, + ) -> DeviceManagerResult>>> { + let ioapic = if userspace_ioapic { + // Create IOAPIC + let ioapic = Arc::new(Mutex::new(ioapic::Ioapic::new( + vm_info.vm_fd.clone(), + APIC_START, + ))); + + address_manager + .mmio_bus + .insert(ioapic.clone(), IOAPIC_START.0, IOAPIC_SIZE) + .map_err(DeviceManagerError::BusError)?; + Some(ioapic) + } else { + None + }; + + Ok(ioapic) + } + #[allow(unused_variables)] fn add_acpi_device( address_manager: &Arc,