Skip to main content

Vm

Struct Vm 

Source
pub struct Vm { /* private fields */ }
Expand description

A live unkernel Linux VM running inside wasmtime.

Implementations§

Source§

impl Vm

Source

pub fn boot(cfg: VmConfig) -> Result<Self>

Boot an air-gapped Linux VM with the given VmConfig, waiting until kwtty is ready and mounting any configured host directories over 9P2000.L.

Source

pub fn exec(&self, opts: &ExecOptions) -> Result<ExecResult>

Execute a command inside the guest Linux VM and capture stdout, stderr, and exit status.

Source

pub fn mount( &self, host_path: &Path, guest_path: &str, read_only: bool, ) -> Result<()>

Dynamically mount an additional host directory at runtime via 9P2000.L.

Source

pub fn mount_cow(&self, host_path: &Path, guest_path: &str) -> Result<()>

Dynamically mount an additional host directory in copy-on-write (:cow) staging mode.

Source

pub fn snapshot(&self) -> Result<VmSnapshot>

Capture a forkable Tier-A VmSnapshot of the persistent ext4 data disk (if attached) and every :cow 9P workspace overlay.

When a writable data disk is attached and the VM is running, flushes the guest ext4 page cache with sync first so all OS/package writes are persisted in the snapshot.

Source

pub fn branch_from_snapshot( snap: &VmSnapshot, net: Option<NetConfig>, monitor: Option<MonitorConfig>, ) -> Result<Self>

Boot an independent branch VM from an existing VmSnapshot.

Both the branch’s ext4 disk overlay and all :cow workspaces start from the exact captured state and diverge completely independently without touching the host disk or host files.

Source

pub fn workspace_diff(&self, guest_path: &str) -> Result<WorkspaceDiff>

Return the pending created/modified/deleted file diff for a :cow workspace mount.

Source

pub fn diff_all_workspaces(&self) -> Vec<WorkspaceDiff>

Return pending diffs for all :cow workspace mounts.

Source

pub fn read_workspace_file( &self, guest_path: &str, rel_path: &str, ) -> Result<Option<Vec<u8>>>

Read the staged (or underlying host) bytes of rel_path inside a :cow workspace mount.

Source

pub fn commit_workspace(&self, guest_path: &str) -> Result<WorkspaceDiff>

Commit staged :cow changes for guest_path back to the real host directory and return the diff that was applied.

Source

pub fn discard_workspace(&self, guest_path: &str) -> Result<()>

Discard all staged :cow mutations for guest_path, rolling the workspace back to the unmodified host directory contents and invalidating guest VFS dentries/page caches.

Source

pub fn active_processes(&self) -> Vec<ProcInfo>

List live guest Linux processes via untamperable host-side SharedMemory VMI.

Works even while the VM is completely frozen via Vm::pause.

Source

pub fn current_process(&self) -> Option<ProcInfo>

Return the currently scheduled guest Linux process via host-side VMI (if calibrated).

Source

pub fn vmi_offsets(&self) -> Option<TaskStructOffsets>

Return the dynamically auto-calibrated Linux task_struct offsets (if calibration succeeded).

Source

pub fn mitm_ca_pem(&self) -> Option<&str>

Return the ephemeral MITM Root CA PEM certificate if --mitm-tls is active on this VM.

Source

pub fn interactive_pty( &self, cols: u16, rows: u16, user: Option<&str>, cwd: Option<&str>, program: Option<&str>, args: &[String], ) -> Result<i32>

Attach an interactive PTY shell to host stdin/stdout.

Source

pub fn jit_stats(&self) -> JitStats

Source

pub fn timings(&self) -> BootTimings

Source

pub fn sandbox_status(&self) -> &SandboxStatus

Source

pub fn switches(&self) -> i32

Source

pub fn timed_out(&self) -> bool

Source

pub fn pause(&self) -> bool

Freeze the entire guest Linux VM immediately via Wasmtime epoch interruption (also pauses guest monotonic time). Returns true if transitioned running -> paused.

Source

pub fn resume(&self) -> Option<u64>

Resume a previously paused guest Linux VM. Returns Some(paused_ms) if transitioned paused -> running.

Source

pub fn is_paused(&self) -> bool

Whether the guest Linux VM is currently frozen.

Source

pub fn pending_approvals(&self) -> Vec<ApprovalRequest>

Snapshot pending interactive approval requests currently waiting on host judgment.

Source

pub fn resolve_approval( &self, approval_id: u64, decision: ApprovalDecision, ) -> bool

Resolve a pending approval request by approval_id.

Source

pub fn monitor(&self) -> &Arc<Monitor> ⓘ

Access the underlying host Monitor for advanced telemetry/approval integration.

Source

pub fn shutdown(&self)

Gracefully power off the guest Linux kernel and flush persistent disks.

Trait Implementations§

Source§

impl Drop for Vm

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Vm

§

impl !RefUnwindSafe for Vm

§

impl !UnwindSafe for Vm

§

impl Forget for Vm

§

impl Move for Vm

§

impl Send for Vm
where Arc<VmState>: Send, Arc<VsockHost>: Send, Arc<P9Server>: Send, Arc<Monitor>: Send, Arc<VmiTracker>: Send, RawVecInner: Send, RawTable<(u64, Box<[u8; 4096]>)>: Send, NodeRef<Owned, String, CowEntry, LeafOrInternal>: Send, BoxRaw<(String, CowEntry)>: Send, RawTable<(String, ())>: Send, Arc<Mutex<File>>: Send, Arc<VirtualSwitch>: Send, Arc<dyn Fn(AuditEvent) + Send + Sync>: Send, Arc<dyn Fn(&ApprovalRequest) -> ApprovalDecision + Send + Sync>: Send, Mutex<Option<JoinHandle<()>>>: Send,

§

impl Sync for Vm
where Arc<VmState>: Sync, Arc<VsockHost>: Sync, Arc<P9Server>: Sync, Arc<Monitor>: Sync, Arc<VmiTracker>: Sync, RawVecInner: Sync, RawTable<(u64, Box<[u8; 4096]>)>: Sync, NodeRef<Owned, String, CowEntry, LeafOrInternal>: Sync, BoxRaw<(String, CowEntry)>: Sync, RawTable<(String, ())>: Sync, Arc<Mutex<File>>: Sync, Arc<VirtualSwitch>: Sync, Arc<dyn Fn(AuditEvent) + Send + Sync>: Sync, Arc<dyn Fn(&ApprovalRequest) -> ApprovalDecision + Send + Sync>: Sync, Mutex<Option<JoinHandle<()>>>: Sync,

§

impl Unpin for Vm
where Arc<VmState>: Unpin, Arc<VsockHost>: Unpin, Arc<P9Server>: Unpin, Arc<Monitor>: Unpin, Arc<VmiTracker>: Unpin, *const u8 is !null: Unpin, Box<[u8; 4096]>: Unpin, *const LeafNode<String, CowEntry> is !null: Unpin, Box<(String, CowEntry)>: Unpin, Arc<Mutex<File>>: Unpin, Arc<VirtualSwitch>: Unpin, Arc<dyn Fn(AuditEvent) + Send + Sync>: Unpin, Arc<dyn Fn(&ApprovalRequest) -> ApprovalDecision + Send + Sync>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for Vm
where *const ArcInner<VmState> is !null: UnsafeUnpin, PhantomData<ArcInner<VmState>>: UnsafeUnpin, *const ArcInner<VsockHost> is !null: UnsafeUnpin, PhantomData<ArcInner<VsockHost>>: UnsafeUnpin, *const ArcInner<P9Server> is !null: UnsafeUnpin, PhantomData<ArcInner<P9Server>>: UnsafeUnpin, *const ArcInner<Monitor> is !null: UnsafeUnpin, PhantomData<ArcInner<Monitor>>: UnsafeUnpin, *const ArcInner<VmiTracker> is !null: UnsafeUnpin, PhantomData<ArcInner<VmiTracker>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<MountSpec>: UnsafeUnpin, PhantomData<(u64, Box<[u8; 4096]>)>: UnsafeUnpin, PhantomData<WorkspaceSnapshot>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<PortForward>: UnsafeUnpin, *const ArcInner<Mutex<File>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<File>>>: UnsafeUnpin, *const ArcInner<VirtualSwitch> is !null: UnsafeUnpin, PhantomData<ArcInner<VirtualSwitch>>: UnsafeUnpin, *const ArcInner<dyn Fn(AuditEvent) + Send + Sync> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(AuditEvent) + Send + Sync>>: UnsafeUnpin, *const ArcInner<dyn Fn(&ApprovalRequest) -> ApprovalDecision + Send + Sync> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&ApprovalRequest) -> ApprovalDecision + Send + Sync>>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.