pub struct HmVm { /* private fields */ }Expand description
High-level orchestrator that drives the VM lifecycle.
HmVm composes a VmBackend with an ImageRegistry to provide
cache-aware execution: if a cached snapshot already exists for a given
caching key the expensive create-inject-exec cycle is skipped entirely.
Implementations§
Source§impl HmVm
impl HmVm
Sourcepub fn new(
backend: Arc<dyn VmBackend>,
registry: ImageRegistry,
config: VmConfig,
) -> Self
pub fn new( backend: Arc<dyn VmBackend>, registry: ImageRegistry, config: VmConfig, ) -> Self
Create a new orchestrator from the given backend, registry and config.
Sourcepub async fn execute(
&self,
action: Action,
policy: CachingPolicy,
sink: &dyn OutputSink,
) -> Result<ExecutionResult>
pub async fn execute( &self, action: Action, policy: CachingPolicy, sink: &dyn OutputSink, ) -> Result<ExecutionResult>
Execute an Action inside a VM, obeying the given CachingPolicy.
§Cache behaviour
When the policy is CachingPolicy::Cache the registry is consulted
first. A cache hit that still exists in the backend returns immediately.
On a successful (exit-code 0) execution the resulting snapshot is stored
in the registry; evicted entries are cleaned up in the backend.
§Errors
Returns an error if the backend fails to create, restore, inject, or execute. Best-effort cleanup is performed even on failure paths.
Sourcepub async fn remove_snapshot(&self, snapshot: &SnapshotId) -> Result<()>
pub async fn remove_snapshot(&self, snapshot: &SnapshotId) -> Result<()>
Remove a snapshot from the backend store.
Used to reap ephemeral (uncached) leaf snapshots once a run finishes —
CachingPolicy::None commits a transient ephemeral:* image purely for
downstream container lineage, and nothing in the registry ever evicts
it. The scheduler reaps these explicitly at run end.
§Errors
Returns an error if the backend fails to remove the snapshot.