diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 8f1424b1e..3ff1a3e53 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -98,6 +98,27 @@ pub trait MsiInterruptGroupOps { fn set_gsi_routes(&self, routes: &HashMap>) -> Result<()>; } +use hypervisor::IrqRoutingEntry; +impl MsiInterruptGroupOps for MsiInterruptGroup { + fn set_gsi_routes(&self, routes: &HashMap>) -> Result<()> { + let mut entry_vec: Vec = Vec::new(); + for (_, entry) in routes.iter() { + if entry.masked { + continue; + } + + entry_vec.push(entry.route); + } + + self.vm.set_gsi_routing(&entry_vec).map_err(|e| { + io::Error::new( + io::ErrorKind::Other, + format!("Failed setting GSI routing: {}", e), + ) + }) + } +} + pub trait RoutingEntryExt { fn make_entry( vm: &Arc, @@ -339,7 +360,6 @@ pub mod kvm { use hypervisor::kvm::KVM_MSI_VALID_DEVID; use hypervisor::kvm::{kvm_irq_routing_entry, KVM_IRQ_ROUTING_IRQCHIP, KVM_IRQ_ROUTING_MSI}; - type KvmMsiInterruptGroup = MsiInterruptGroup; type KvmRoutingEntry = RoutingEntry; pub type KvmMsiInterruptManager = MsiInterruptManager; @@ -393,29 +413,6 @@ pub mod kvm { )) } } - - impl MsiInterruptGroupOps for KvmMsiInterruptGroup { - fn set_gsi_routes( - &self, - routes: &HashMap>, - ) -> Result<()> { - let mut entry_vec: Vec = Vec::new(); - for (_, entry) in routes.iter() { - if entry.masked { - continue; - } - - entry_vec.push(entry.route); - } - - self.vm.set_gsi_routing(&entry_vec).map_err(|e| { - io::Error::new( - io::ErrorKind::Other, - format!("Failed setting GSI routing: {}", e), - ) - }) - } - } } #[cfg(feature = "mshv")] @@ -423,7 +420,6 @@ pub mod mshv { use super::*; use hypervisor::mshv::*; - type MshvMsiInterruptGroup = MsiInterruptGroup; type MshvRoutingEntry = RoutingEntry; pub type MshvMsiInterruptManager = MsiInterruptManager; @@ -454,29 +450,6 @@ pub mod mshv { )) } } - - impl MsiInterruptGroupOps for MshvMsiInterruptGroup { - fn set_gsi_routes( - &self, - routes: &HashMap>, - ) -> Result<()> { - let mut entry_vec: Vec = Vec::new(); - for (_, entry) in routes.iter() { - if entry.masked { - continue; - } - - entry_vec.push(entry.route); - } - - self.vm.set_gsi_routing(&entry_vec).map_err(|e| { - io::Error::new( - io::ErrorKind::Other, - format!("Failed setting GSI routing: {}", e), - ) - }) - } - } } #[cfg(target_arch = "aarch64")]