vmm: interrupts: clearly separate MsiInterruptGroup and InterruptRoute

MsiInterruptGroup doesn't need to know the internal field names of
InterruptRoute. Introduce two helper functions to eliminate references
to irq_fd. This is done similarly to the enable and disable helper
functions.

Also drop the pub keyword from InterruptRoute fields. It is not needed
anymore.

No functional change.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2020-09-29 11:07:54 +00:00 committed by Sebastien Boeuf
parent db5d42ad41
commit 4ef97d8ddb

View File

@ -19,8 +19,8 @@ use vmm_sys_util::eventfd::EventFd;
pub type Result<T> = std::io::Result<T>;
struct InterruptRoute {
pub gsi: u32,
pub irq_fd: EventFd,
gsi: u32,
irq_fd: EventFd,
registered: AtomicBool,
}
@ -69,6 +69,14 @@ impl InterruptRoute {
Ok(())
}
pub fn trigger(&self) -> Result<()> {
self.irq_fd.write(1)
}
pub fn notifier(&self) -> Option<&EventFd> {
Some(&self.irq_fd)
}
}
pub struct RoutingEntry<E> {
@ -132,7 +140,7 @@ where
fn trigger(&self, index: InterruptIndex) -> Result<()> {
if let Some(route) = self.irq_routes.get(&index) {
return route.irq_fd.write(1);
return route.trigger();
}
Err(io::Error::new(
@ -143,7 +151,7 @@ where
fn notifier(&self, index: InterruptIndex) -> Option<&EventFd> {
if let Some(route) = self.irq_routes.get(&index) {
return Some(&route.irq_fd);
return route.notifier();
}
None