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 <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2020-06-25 14:49:40 +00:00 committed by Rob Bradford
parent f3c8f827cc
commit 574cab6990
2 changed files with 9 additions and 17 deletions

View File

@ -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<Mutex<HashMap<u32, KvmRoutingEntry>>> =
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 {

View File

@ -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<Mutex<SystemAllocator>>,
vm_fd: Arc<dyn hypervisor::Vm>,
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>,
) -> Self {
pub fn new(allocator: Arc<Mutex<SystemAllocator>>, vm_fd: Arc<dyn hypervisor::Vm>) -> 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,