Skip to main content

VmProvider

Trait VmProvider 

Source
pub trait VmProvider:
    Send
    + Sync
    + 'static {
    // Required methods
    fn create_vm(&self, vm_id: &str) -> VmRuntimeResult<()>;
    fn start_vm(&self, vm_id: &str) -> VmRuntimeResult<()>;
    fn stop_vm(&self, vm_id: &str) -> VmRuntimeResult<()>;
    fn snapshot_vm(&self, vm_id: &str, snapshot_id: &str) -> VmRuntimeResult<()>;
    fn destroy_vm(&self, vm_id: &str) -> VmRuntimeResult<()>;

    // Provided methods
    fn create_vm_with_spec(
        &self,
        vm_id: &str,
        _spec: &VmSpec,
    ) -> VmRuntimeResult<()> { ... }
    fn rename_vm(
        &self,
        _old_vm_id: &str,
        _new_vm_id: &str,
    ) -> VmRuntimeResult<()> { ... }
}
Expand description

State-changing operations on microVMs, executed by lifecycle jobs.

Required Methods§

Source

fn create_vm(&self, vm_id: &str) -> VmRuntimeResult<()>

Provision a new microVM with workspace defaults. Fails if vm_id is already in use.

Source

fn start_vm(&self, vm_id: &str) -> VmRuntimeResult<()>

Start a created or stopped microVM. Fails if already running or destroyed.

Source

fn stop_vm(&self, vm_id: &str) -> VmRuntimeResult<()>

Stop a running microVM. Fails if not currently running.

Source

fn snapshot_vm(&self, vm_id: &str, snapshot_id: &str) -> VmRuntimeResult<()>

Capture the state of a microVM as a named snapshot. Fails if the VM is destroyed or the snapshot name already exists.

Source

fn destroy_vm(&self, vm_id: &str) -> VmRuntimeResult<()>

Tear down a microVM. Terminal state — cannot be restarted.

Provided Methods§

Source

fn create_vm_with_spec( &self, vm_id: &str, _spec: &VmSpec, ) -> VmRuntimeResult<()>

Provision a new microVM with per-VM configuration overrides.

If spec.restore_from is set, the VM boots from the referenced snapshot via PUT /snapshot/load instead of cold-booting; the rest of the spec’s cold-boot fields are ignored except for any crate::model::SnapshotRef::network_overrides.

Default implementation delegates to create_vm and ignores the spec — adequate for simple providers (e.g. the in-memory test adapter) where the spec has no semantics. Real adapters should override.

Source

fn rename_vm(&self, _old_vm_id: &str, _new_vm_id: &str) -> VmRuntimeResult<()>

Rename a VM. Used for warm-pool handoff: a pre-restored VM that swaps its identifier onto a new tenant request without going through a full snapshot/load round-trip.

Default implementation returns VmRuntimeError::Unsupported. Providers that support pooled VMs should override.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§