pub struct Vm { /* private fields */ }Expand description
Handle to a configured VM ready to enter.
Created via VmBuilder::build().
Implementations§
Source§impl Vm
impl Vm
Sourcepub fn exit_handle(&self) -> ExitHandle
pub fn exit_handle(&self) -> ExitHandle
Get a cloneable handle that triggers VM exit from any thread.
Must be called before enter(). Background tasks
use this to shut down the VMM (e.g. idle timeout, max duration).
Sourcepub fn exit_code(&self) -> Arc<AtomicI32>
pub fn exit_code(&self) -> Arc<AtomicI32>
Get a shared reference to the VM exit code.
The VMM writes the guest exit code here before invoking exit
observers. Read it inside an on_exit
closure to record the exit status.
Sentinel value i32::MAX means “not yet set”.
Sourcepub fn metrics_handle(&self) -> MetricsHandle
pub fn metrics_handle(&self) -> MetricsHandle
Get a cloneable handle for VM metrics.
Must be called before enter() if the caller needs to
sample metrics while the VM is running, because enter() never returns
on a successful boot.
Sourcepub fn enter(self) -> Result<Infallible>
pub fn enter(self) -> Result<Infallible>
Start the VM. This call never returns on success — the VMM calls
_exit() when the guest shuts down, killing the entire process.
Only returns Err if something fails before the VMM takes over.