pub trait VmHandler: Send + Sync {
// Required methods
fn stop(&mut self, signal: i32, timeout_ms: u64) -> Result<(), BoxError>;
fn metrics(&self) -> VmMetrics;
fn is_running(&self) -> bool;
fn pid(&self) -> u32;
// Provided methods
fn has_exited(&self) -> bool { ... }
fn exit_code(&self) -> Option<i32> { ... }
fn try_wait_exit(&mut self) -> Result<Option<i32>, BoxError> { ... }
}Expand description
Lifecycle operations on a running VM.
Separates runtime operations (stop, metrics) from spawning (VmmProvider). Allows reconnecting to existing VMs by constructing a handler from a PID.
Required Methods§
Sourcefn stop(&mut self, signal: i32, timeout_ms: u64) -> Result<(), BoxError>
fn stop(&mut self, signal: i32, timeout_ms: u64) -> Result<(), BoxError>
Stop the VM. Sends signal first, then SIGKILL after timeout_ms.
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
Check if the VM process is still alive.
Provided Methods§
Sourcefn has_exited(&self) -> bool
fn has_exited(&self) -> bool
Whether the VM process has exited, treating a zombie (an exited child not yet reaped by its parent) as exited.
Distinct from !is_running(): shim handlers implement is_running with
kill(pid, 0), which still succeeds for a zombie, so a freshly-exited
shim looks alive until its parent reaps it. Boot-readiness waits use this
so a short-lived container’s exit does not stall the wait for the full
timeout. On Linux it inspects /proc/<pid> process state; elsewhere it
falls back to !is_running().
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".