From 0f1396acefac1c26f44b311f0d5ae1ae3fee77dc Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 27 Feb 2020 11:36:30 +0100 Subject: [PATCH] vmm: Insert PCI device hotplug operation region on IO bus Through the BusDevice implementation from the DeviceManager, and by inserting the DeviceManager on the IO bus for a specific IO port range, the VMM now has the ability to handle PCI device hotplug. Signed-off-by: Sebastien Boeuf --- vmm/src/device_manager.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 79bef4076..90459a6a3 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -502,7 +502,7 @@ impl DeviceManager { .map_err(DeviceManagerError::BusError)?; let mut device_manager = DeviceManager { - address_manager, + address_manager: Arc::clone(&address_manager), console: Arc::new(Console::default()), ioapic: Some(ioapic), _mmap_regions, @@ -543,7 +543,27 @@ impl DeviceManager { device_manager.virtio_devices = virtio_devices; - Ok(Arc::new(Mutex::new(device_manager))) + let device_manager = Arc::new(Mutex::new(device_manager)); + + #[cfg(feature = "acpi")] + address_manager + .allocator + .lock() + .unwrap() + .allocate_io_addresses(Some(GuestAddress(0xae00)), 0x10, None) + .ok_or(DeviceManagerError::AllocateIOPort)?; + + #[cfg(feature = "acpi")] + address_manager + .io_bus + .insert( + Arc::clone(&device_manager) as Arc>, + 0xae00, + 0x10, + ) + .map_err(DeviceManagerError::BusError)?; + + Ok(device_manager) } #[allow(unused_variables)]