pub trait VmiHandler<Os>where
Os: VmiOs,{
type Output;
// Required method
fn handle_event(
&mut self,
event: VmiContext<'_, Os>,
) -> VmiEventResponse<Os::Architecture>;
// Provided methods
fn handle_timeout(&mut self, _session: &VmiSession<'_, Os>) { ... }
fn handle_interrupted(&mut self, _session: &VmiSession<'_, Os>) { ... }
fn cleanup(&mut self, _session: &VmiSession<'_, Os>) { ... }
fn poll(&self) -> Option<Self::Output> { ... }
}Expand description
A trait for handling VMI events.
A factory that creates a handler implementing this trait is passed to
the VmiSession::handle method to handle VMI events.
Required Associated Types§
Required Methods§
Sourcefn handle_event(
&mut self,
event: VmiContext<'_, Os>,
) -> VmiEventResponse<Os::Architecture>
fn handle_event( &mut self, event: VmiContext<'_, Os>, ) -> VmiEventResponse<Os::Architecture>
Called for each VMI event.
The returned VmiEventResponse tells the hypervisor how to resume
the vCPU that triggered the event.
Provided Methods§
Sourcefn handle_timeout(&mut self, _session: &VmiSession<'_, Os>)
fn handle_timeout(&mut self, _session: &VmiSession<'_, Os>)
Called when the event loop times out waiting for the next event.
This is useful for periodic housekeeping while the guest is idle.
Sourcefn handle_interrupted(&mut self, _session: &VmiSession<'_, Os>)
fn handle_interrupted(&mut self, _session: &VmiSession<'_, Os>)
Called when the event loop is interrupted by a signal.
Typically used to initiate a graceful shutdown, by setting a flag
that causes poll to return Some on the next call.
Sourcefn cleanup(&mut self, _session: &VmiSession<'_, Os>)
fn cleanup(&mut self, _session: &VmiSession<'_, Os>)
Called once before the session tears down monitoring.
This gives the handler an opportunity to release resources that
depend on the session (views, memory access permissions, event
monitors) before the session calls reset_state.