vmm: interrupt: generify KvmMsiInterruptManager

The observation is only the route entry is hypervisor dependent.

Keep a definition of KvmMsiInterruptManager to avoid too much code
churn.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2020-06-27 15:28:53 +00:00 committed by Rob Bradford
parent d5149e95cb
commit 0ec39da90c

View File

@ -320,19 +320,21 @@ pub struct LegacyUserspaceInterruptManager {
ioapic: Arc<Mutex<dyn InterruptController>>, ioapic: Arc<Mutex<dyn InterruptController>>,
} }
pub struct KvmMsiInterruptManager { pub struct MsiInterruptManager<E> {
allocator: Arc<Mutex<SystemAllocator>>, allocator: Arc<Mutex<SystemAllocator>>,
vm_fd: Arc<dyn hypervisor::Vm>, vm_fd: Arc<dyn hypervisor::Vm>,
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>, gsi_msi_routes: Arc<Mutex<HashMap<u32, RoutingEntry<E>>>>,
} }
pub type KvmMsiInterruptManager = MsiInterruptManager<kvm_irq_routing_entry>;
impl LegacyUserspaceInterruptManager { impl LegacyUserspaceInterruptManager {
pub fn new(ioapic: Arc<Mutex<dyn InterruptController>>) -> Self { pub fn new(ioapic: Arc<Mutex<dyn InterruptController>>) -> Self {
LegacyUserspaceInterruptManager { ioapic } LegacyUserspaceInterruptManager { ioapic }
} }
} }
impl KvmMsiInterruptManager { impl<E> MsiInterruptManager<E> {
pub fn new(allocator: Arc<Mutex<SystemAllocator>>, vm_fd: Arc<dyn hypervisor::Vm>) -> 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 // 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, // devices. This way, we can maintain the full list of used GSI,
@ -340,7 +342,7 @@ impl KvmMsiInterruptManager {
// another one. // another one.
let gsi_msi_routes = Arc::new(Mutex::new(HashMap::new())); let gsi_msi_routes = Arc::new(Mutex::new(HashMap::new()));
KvmMsiInterruptManager { MsiInterruptManager {
allocator, allocator,
vm_fd, vm_fd,
gsi_msi_routes, gsi_msi_routes,