From d5149e95cba4de8d1ad70e7e125de52ce88a912d Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Sat, 27 Jun 2020 15:22:24 +0000 Subject: [PATCH] vmm: interrupt: generify KvmRoutingEntry and KvmMsiInterruptGroup The observation is that only the route field is hypervisor specific. Provide a new function in blanket implementation. Also redefine KvmRoutingEntry with RoutingEntry to avoid code churn. Signed-off-by: Wei Liu --- vmm/src/interrupt.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 52a90f80d..f482fc74f 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -103,30 +103,36 @@ impl InterruptRoute { } } -struct KvmRoutingEntry { - kvm_route: kvm_irq_routing_entry, +struct RoutingEntry { + route: E, masked: bool, } -struct KvmMsiInterruptGroup { +type KvmRoutingEntry = RoutingEntry; + +struct MsiInterruptGroup { vm_fd: Arc, - gsi_msi_routes: Arc>>, + gsi_msi_routes: Arc>>>, irq_routes: HashMap, } -impl KvmMsiInterruptGroup { +impl MsiInterruptGroup { fn new( vm_fd: Arc, - gsi_msi_routes: Arc>>, + gsi_msi_routes: Arc>>>, irq_routes: HashMap, ) -> Self { - KvmMsiInterruptGroup { + MsiInterruptGroup { vm_fd, gsi_msi_routes, irq_routes, } } +} +type KvmMsiInterruptGroup = MsiInterruptGroup; + +impl KvmMsiInterruptGroup { fn set_kvm_gsi_routes(&self) -> Result<()> { let gsi_msi_routes = self.gsi_msi_routes.lock().unwrap(); let mut entry_vec: Vec = Vec::new(); @@ -135,7 +141,7 @@ impl KvmMsiInterruptGroup { continue; } - entry_vec.push(entry.kvm_route); + entry_vec.push(entry.route); } let mut irq_routing = @@ -229,7 +235,7 @@ impl InterruptSourceGroup for KvmMsiInterruptGroup { kvm_route.u.msi.data = cfg.data; let kvm_entry = KvmRoutingEntry { - kvm_route, + route: kvm_route, masked: false, };