diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 1ee4de91d..9b1951eaf 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -268,20 +268,21 @@ impl InterruptManager for KvmInterruptManager { base: InterruptIndex, count: InterruptIndex, ) -> Result>> { - let mut allocator = self.allocator.lock().unwrap(); - - let mut irq_routes: HashMap = - HashMap::with_capacity(count as usize); - for i in base..base + count { - irq_routes.insert(i, InterruptRoute::new(&mut allocator)?); - } - let interrupt_source_group: Arc> = match interrupt_type { - PCI_MSI_IRQ => Arc::new(Box::new(MsiInterruptGroup::new( - self.vm_fd.clone(), - self.gsi_msi_routes.clone(), - irq_routes, - ))), + PCI_MSI_IRQ => { + let mut allocator = self.allocator.lock().unwrap(); + let mut irq_routes: HashMap = + HashMap::with_capacity(count as usize); + for i in base..base + count { + irq_routes.insert(i, InterruptRoute::new(&mut allocator)?); + } + + Arc::new(Box::new(MsiInterruptGroup::new( + self.vm_fd.clone(), + self.gsi_msi_routes.clone(), + irq_routes, + ))) + } _ => { return Err(io::Error::new( io::ErrorKind::Other,