mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Move irq_routes creation to specific MSI use case
When KvmInterruptManager initializes a new InterruptSourceGroup, it's only for PCI_MSI_IRQ case that it needs to allocate the GSI and create a new InterruptRoute. That's why this commit moves the general code into the specific use case. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
d34f31fe7b
commit
2aabf58bf5
+14
-13
@@ -268,20 +268,21 @@ impl InterruptManager for KvmInterruptManager {
|
|||||||
base: InterruptIndex,
|
base: InterruptIndex,
|
||||||
count: InterruptIndex,
|
count: InterruptIndex,
|
||||||
) -> Result<Arc<Box<dyn InterruptSourceGroup>>> {
|
) -> Result<Arc<Box<dyn InterruptSourceGroup>>> {
|
||||||
let mut allocator = self.allocator.lock().unwrap();
|
|
||||||
|
|
||||||
let mut irq_routes: HashMap<InterruptIndex, InterruptRoute> =
|
|
||||||
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<Box<dyn InterruptSourceGroup>> = match interrupt_type {
|
let interrupt_source_group: Arc<Box<dyn InterruptSourceGroup>> = match interrupt_type {
|
||||||
PCI_MSI_IRQ => Arc::new(Box::new(MsiInterruptGroup::new(
|
PCI_MSI_IRQ => {
|
||||||
self.vm_fd.clone(),
|
let mut allocator = self.allocator.lock().unwrap();
|
||||||
self.gsi_msi_routes.clone(),
|
let mut irq_routes: HashMap<InterruptIndex, InterruptRoute> =
|
||||||
irq_routes,
|
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(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
|
|||||||
Reference in New Issue
Block a user