From f5c550affb424546378da5fbf50775b8db574246 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 24 Mar 2021 16:29:06 +0000 Subject: [PATCH] vmm: interrupt: simplify interrupt handling traits Drop the generic type E and use IrqRoutngEntry directly. This allows dropping a bunch of trait bounds from code. Signed-off-by: Wei Liu --- vmm/src/interrupt.rs | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 3ff1a3e53..a8e9082d7 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -4,6 +4,7 @@ // use devices::interrupt_controller::InterruptController; +use hypervisor::IrqRoutingEntry; use std::collections::HashMap; use std::io; use std::sync::atomic::{AtomicBool, Ordering}; @@ -83,23 +84,18 @@ impl InterruptRoute { } } -pub struct RoutingEntry { - route: E, +pub struct RoutingEntry { + route: IrqRoutingEntry, masked: bool, } -pub struct MsiInterruptGroup { +pub struct MsiInterruptGroup { vm: Arc, - gsi_msi_routes: Arc>>>, + gsi_msi_routes: Arc>>>, irq_routes: HashMap, } -pub trait MsiInterruptGroupOps { - fn set_gsi_routes(&self, routes: &HashMap>) -> Result<()>; -} - -use hypervisor::IrqRoutingEntry; -impl MsiInterruptGroupOps for MsiInterruptGroup { +impl MsiInterruptGroup { fn set_gsi_routes(&self, routes: &HashMap>) -> Result<()> { let mut entry_vec: Vec = Vec::new(); for (_, entry) in routes.iter() { @@ -127,10 +123,10 @@ pub trait RoutingEntryExt { ) -> Result>; } -impl MsiInterruptGroup { +impl MsiInterruptGroup { fn new( vm: Arc, - gsi_msi_routes: Arc>>>, + gsi_msi_routes: Arc>>>, irq_routes: HashMap, ) -> Self { MsiInterruptGroup { @@ -141,12 +137,7 @@ impl MsiInterruptGroup { } } -impl InterruptSourceGroup for MsiInterruptGroup -where - E: Send + Sync, - RoutingEntry: RoutingEntryExt, - MsiInterruptGroup: MsiInterruptGroupOps, -{ +impl InterruptSourceGroup for MsiInterruptGroup { fn enable(&self) -> Result<()> { for (_, route) in self.irq_routes.iter() { route.enable(&self.vm)?; @@ -277,10 +268,10 @@ pub struct LegacyUserspaceInterruptManager { ioapic: Arc>, } -pub struct MsiInterruptManager { +pub struct MsiInterruptManager { allocator: Arc>, vm: Arc, - gsi_msi_routes: Arc>>>, + gsi_msi_routes: Arc>>>, } impl LegacyUserspaceInterruptManager { @@ -289,7 +280,7 @@ impl LegacyUserspaceInterruptManager { } } -impl MsiInterruptManager { +impl MsiInterruptManager { pub fn new(allocator: Arc>, vm: 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, @@ -323,12 +314,7 @@ impl InterruptManager for LegacyUserspaceInterruptManager { } } -impl InterruptManager for MsiInterruptManager -where - E: Send + Sync + 'static, - RoutingEntry: RoutingEntryExt, - MsiInterruptGroup: MsiInterruptGroupOps, -{ +impl InterruptManager for MsiInterruptManager { type GroupConfig = MsiIrqGroupConfig; fn create_group(