pub struct Vm { /* private fields */ }Expand description
A live unkernel Linux VM running inside wasmtime.
Implementations§
Source§impl Vm
impl Vm
Sourcepub fn boot(cfg: VmConfig) -> Result<Self>
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.
Sourcepub fn exec(&self, opts: &ExecOptions) -> Result<ExecResult>
pub fn exec(&self, opts: &ExecOptions) -> Result<ExecResult>
Execute a command inside the guest Linux VM and capture stdout, stderr, and exit status.
Sourcepub fn mount(
&self,
host_path: &Path,
guest_path: &str,
read_only: bool,
) -> Result<()>
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.
Sourcepub fn mount_cow(&self, host_path: &Path, guest_path: &str) -> Result<()>
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.
Sourcepub fn snapshot(&self) -> Result<VmSnapshot>
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.
Sourcepub fn branch_from_snapshot(
snap: &VmSnapshot,
net: Option<NetConfig>,
monitor: Option<MonitorConfig>,
) -> Result<Self>
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.
Sourcepub fn workspace_diff(&self, guest_path: &str) -> Result<WorkspaceDiff>
pub fn workspace_diff(&self, guest_path: &str) -> Result<WorkspaceDiff>
Return the pending created/modified/deleted file diff for a :cow workspace mount.
Sourcepub fn diff_all_workspaces(&self) -> Vec<WorkspaceDiff>
pub fn diff_all_workspaces(&self) -> Vec<WorkspaceDiff>
Return pending diffs for all :cow workspace mounts.
Sourcepub fn read_workspace_file(
&self,
guest_path: &str,
rel_path: &str,
) -> Result<Option<Vec<u8>>>
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.
Sourcepub fn commit_workspace(&self, guest_path: &str) -> Result<WorkspaceDiff>
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.
Sourcepub fn discard_workspace(&self, guest_path: &str) -> Result<()>
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.
Sourcepub fn active_processes(&self) -> Vec<ProcInfo>
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.
Sourcepub fn current_process(&self) -> Option<ProcInfo>
pub fn current_process(&self) -> Option<ProcInfo>
Return the currently scheduled guest Linux process via host-side VMI (if calibrated).
Sourcepub fn vmi_offsets(&self) -> Option<TaskStructOffsets>
pub fn vmi_offsets(&self) -> Option<TaskStructOffsets>
Return the dynamically auto-calibrated Linux task_struct offsets (if calibration succeeded).
Sourcepub fn mitm_ca_pem(&self) -> Option<&str>
pub fn mitm_ca_pem(&self) -> Option<&str>
Return the ephemeral MITM Root CA PEM certificate if --mitm-tls is active on this VM.
Sourcepub fn interactive_pty(
&self,
cols: u16,
rows: u16,
user: Option<&str>,
cwd: Option<&str>,
program: Option<&str>,
args: &[String],
) -> Result<i32>
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.
pub fn jit_stats(&self) -> JitStats
pub fn timings(&self) -> BootTimings
pub fn sandbox_status(&self) -> &SandboxStatus
pub fn switches(&self) -> i32
pub fn timed_out(&self) -> bool
Sourcepub fn pause(&self) -> bool
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.
Sourcepub fn resume(&self) -> Option<u64>
pub fn resume(&self) -> Option<u64>
Resume a previously paused guest Linux VM. Returns Some(paused_ms) if transitioned
paused -> running.
Sourcepub fn pending_approvals(&self) -> Vec<ApprovalRequest>
pub fn pending_approvals(&self) -> Vec<ApprovalRequest>
Snapshot pending interactive approval requests currently waiting on host judgment.
Sourcepub fn resolve_approval(
&self,
approval_id: u64,
decision: ApprovalDecision,
) -> bool
pub fn resolve_approval( &self, approval_id: u64, decision: ApprovalDecision, ) -> bool
Resolve a pending approval request by approval_id.
Trait Implementations§
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 Vmwhere
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 Vmwhere
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 Vmwhere
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 Vmwhere
*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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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