From 574cab699018e882427d27d8710349349c898c15 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 25 Jun 2020 14:49:40 +0000 Subject: [PATCH] vmm: interrupt: create GSI hashmap directly The observation is that the GSI hashmap remains untouched before getting passed into the MSI interrupt manager. We can create that hashmap directly in the interrupt manager's new function. The drops one import from the interrupt module. Signed-off-by: Wei Liu --- vmm/src/device_manager.rs | 12 +----------- vmm/src/interrupt.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 7e12b5aaa..7b1999930 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -14,9 +14,7 @@ use crate::config::ConsoleOutputMode; use crate::config::DeviceConfig; use crate::config::{DiskConfig, FsConfig, NetConfig, PmemConfig, VmConfig, VsockConfig}; use crate::device_tree::{DeviceNode, DeviceTree}; -use crate::interrupt::{ - KvmLegacyUserspaceInterruptManager, KvmMsiInterruptManager, KvmRoutingEntry, -}; +use crate::interrupt::{KvmLegacyUserspaceInterruptManager, KvmMsiInterruptManager}; use crate::memory_manager::{Error as MemoryManagerError, MemoryManager}; #[cfg(feature = "pci_support")] use crate::PciDeviceInfo; @@ -785,13 +783,6 @@ impl DeviceManager { device_tree: Arc::clone(&device_tree), }); - // Create a shared list of GSI that can be shared through all PCI - // devices. This way, we can maintain the full list of used GSI, - // preventing one device from overriding interrupts setting from - // another one. - let kvm_gsi_msi_routes: Arc>> = - Arc::new(Mutex::new(HashMap::new())); - // First we create the MSI interrupt manager, the legacy one is created // later, after the IOAPIC device creation. // The reason we create the MSI one first is because the IOAPIC needs it, @@ -802,7 +793,6 @@ impl DeviceManager { Arc::new(KvmMsiInterruptManager::new( Arc::clone(&address_manager.allocator), vm_fd, - Arc::clone(&kvm_gsi_msi_routes), )); let device_manager = DeviceManager { diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 6a505aa5d..868042774 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -103,7 +103,7 @@ impl InterruptRoute { } } -pub struct KvmRoutingEntry { +struct KvmRoutingEntry { kvm_route: kvm_irq_routing_entry, masked: bool, } @@ -327,11 +327,13 @@ impl KvmLegacyUserspaceInterruptManager { } impl KvmMsiInterruptManager { - pub fn new( - allocator: Arc>, - vm_fd: Arc, - gsi_msi_routes: Arc>>, - ) -> Self { + pub fn new(allocator: Arc>, vm_fd: Arc) -> Self { + // Create a shared list of GSI that can be shared through all PCI + // devices. This way, we can maintain the full list of used GSI, + // preventing one device from overriding interrupts setting from + // another one. + let gsi_msi_routes = Arc::new(Mutex::new(HashMap::new())); + KvmMsiInterruptManager { allocator, vm_fd,