vmm: Create an InterruptManager dedicated to IOAPIC

By introducing a new InterruptManager dedicated to the IOAPIC, we don't
have to solve the chicken and eggs problem about which of the
InterruptManager or the Ioapic should be created first. It's also
totally fine to have two interrupt manager instances as they both share
the same list of GSI routes and the same allocator.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-01-22 18:39:46 +01:00
committed by Rob Bradford
parent 29e668c302
commit 52800a871a
2 changed files with 45 additions and 12 deletions

View File

@@ -276,7 +276,7 @@ pub struct KvmInterruptManager {
allocator: Arc<Mutex<SystemAllocator>>,
vm_fd: Arc<VmFd>,
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>,
ioapic: Arc<Mutex<ioapic::Ioapic>>,
ioapic: Option<Arc<Mutex<ioapic::Ioapic>>>,
}
impl KvmInterruptManager {
@@ -284,7 +284,7 @@ impl KvmInterruptManager {
allocator: Arc<Mutex<SystemAllocator>>,
vm_fd: Arc<VmFd>,
gsi_msi_routes: Arc<Mutex<HashMap<u32, KvmRoutingEntry>>>,
ioapic: Arc<Mutex<ioapic::Ioapic>>,
ioapic: Option<Arc<Mutex<ioapic::Ioapic>>>,
) -> Self {
KvmInterruptManager {
allocator,
@@ -311,10 +311,17 @@ impl InterruptManager for KvmInterruptManager {
));
}
Arc::new(Box::new(LegacyUserspaceInterruptGroup::new(
self.ioapic.clone(),
base as u32,
)))
if let Some(ioapic) = &self.ioapic {
Arc::new(Box::new(LegacyUserspaceInterruptGroup::new(
ioapic.clone(),
base as u32,
)))
} else {
return Err(io::Error::new(
io::ErrorKind::Other,
"No IOAPIC configured, cannot create legacy interrupt group",
));
}
}
PCI_MSI_IRQ => {
let mut allocator = self.allocator.lock().unwrap();