From 4ef97d8ddb92349b2f7a495227cc334e2cd8d9eb Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Tue, 29 Sep 2020 11:07:54 +0000 Subject: [PATCH] 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 --- vmm/src/interrupt.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 8c76db84e..35f0d9a5a 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -19,8 +19,8 @@ use vmm_sys_util::eventfd::EventFd; pub type Result = std::io::Result; 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 { @@ -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