Skip to main content

AgentRequest

Enum AgentRequest 

Source
pub enum AgentRequest {
Show 38 variants Ping, FsNotify { events: Vec<FsNotifyEvent>, }, Pull { image: String, oci_platform: Option<String>, auth: Option<RegistryAuth>, proxy: Option<String>, no_proxy: Option<String>, }, Query { image: String, }, ListImages, GarbageCollect { dry_run: bool, purge_all: bool, }, PrepareOverlay { image: String, workload_id: String, }, CleanupOverlay { workload_id: String, }, FormatStorage, StorageStatus, MemoryStatus, NetworkTest { url: String, }, Shutdown { progress: bool, }, ExportLayer { image_digest: String, layer_index: usize, }, FlattenLayers { lowerdirs: Vec<String>, output: Option<String>, }, BranchpointWait { timeout_ms: u64, }, BranchpointArm, BranchpointPark, BranchpointRelease { env_dotenv: Option<String>, }, BranchpointActivate { env_dotenv: String, env_sourceable: String, env_path: String, branch_env_path: String, require_dir: Option<String>, env_dir: String, activation_token: String, }, BranchpointWaitWorkerReady { token: String, timeout_ms: u64, }, VmExec { command: Vec<String>, env: Vec<(String, String)>, workdir: Option<String>, timeout_ms: Option<u64>, interactive: bool, tty: bool, background: bool, stdin_data: Option<String>, }, Run {
Show 15 fields image: String, command: Vec<String>, env: Vec<(String, String)>, workdir: Option<String>, user: Option<String>, mounts: Vec<(String, String, bool)>, timeout_ms: Option<u64>, interactive: bool, tty: bool, detached: bool, unprivileged: bool, persistent_overlay_id: Option<String>, stdin_data: Option<String>, background: bool, s3_volumes: Vec<S3Volume>,
}, Stdin { data: Vec<u8>, }, Resize { cols: u16, rows: u16, }, FileWrite { path: String, data: Vec<u8>, mode: Option<u32>, uid: Option<u32>, gid: Option<u32>, }, FileWriteBegin { path: String, mode: Option<u32>, uid: Option<u32>, gid: Option<u32>, total_size: u64, }, FileWriteChunk { data: Vec<u8>, done: bool, }, FileRead { path: String, }, ListDirectory { path: String, }, ArchiveDirectory { path: String, }, PodCreate { id: String, rootfs_rel: String, spec_json: String, tty: bool, }, PodStart { id: String, exec_id: Option<String>, }, PodExec { id: String, exec_id: String, process_json: String, tty: bool, }, PodSignal { id: String, exec_id: Option<String>, signal: u32, all: bool, }, PodPids { id: String, }, PodStats { id: String, }, PodDelete { id: String, exec_id: Option<String>, },
}
Expand description

Agent request types (for image management and OCI operations).

Variants§

§

Ping

Ping to check if agent is alive.

§

FsNotify

Inject host-originated fsnotify events into the guest.

virtiofs does not deliver host-side file changes to the guest as fsnotify/inotify events, so inotify-based hot-reload (Vite, webpack, nodemon) never fires when a mounted file is edited on the host. The host watches the mount source and sends the resulting events here; the agent writes them to /proc/smolvm-fsnotify, which fires the matching event on the guest inode so watchers on the (bind-mounted) container path wake up. Each path is a guest-side absolute path (the virtiofs staging path), mask an fsnotify_mask::FS_* bitmask.

Fields

§events: Vec<FsNotifyEvent>

Host-originated filesystem changes to replay as guest fsnotify events.

§

Pull

Pull an OCI image and extract layers.

Fields

§image: String

Image reference (e.g., “alpine:latest”, “docker.io/library/ubuntu:22.04”).

§oci_platform: Option<String>

OCI platform to pull (e.g., “linux/arm64”, “linux/amd64”).

§auth: Option<RegistryAuth>

Optional registry authentication credentials.

§proxy: Option<String>

Proxy URL applied to the registry client (sets HTTP_PROXY and HTTPS_PROXY).

§no_proxy: Option<String>

Comma-separated NO_PROXY list of hosts/CIDRs that bypass the proxy.

§

Query

Query if an image exists locally.

Fields

§image: String

Image reference.

§

ListImages

List all cached images.

§

GarbageCollect

Run garbage collection on unused layers.

Fields

§dry_run: bool

If true, only report what would be deleted.

§purge_all: bool

If true, delete all image manifests and configs first, making all layers unreferenced so they get collected.

§

PrepareOverlay

Prepare overlay rootfs for a workload.

Fields

§image: String

Image reference.

§workload_id: String

Unique workload ID for the overlay.

§

CleanupOverlay

Clean up overlay rootfs for a workload.

Fields

§workload_id: String

Workload ID to clean up.

§

FormatStorage

Format the storage disk (first-time setup).

§

StorageStatus

Get storage disk status.

§

MemoryStatus

Report the guest’s own view of machine memory, read from /proc/meminfo.

The host cannot answer this. macOS charges the VMM’s phys_footprint as internal + compressed, and the compressed part is counted at the pages’ uncompressed size, so an idle guest whose memory has been compressed reports a footprint several times the bytes it actually occupies. Only the guest’s allocator knows what the machine is using.

§

NetworkTest

Test network connectivity directly from the agent (not via chroot). Used to debug TSI networking.

Fields

§url: String

URL to test (e.g., “http://1.1.1.1”)

§

Shutdown

Shutdown the agent.

Fields

§progress: bool

Opt into progress frames while storage is being synchronized.

§

ExportLayer

Export a layer as a tar archive.

Used by smolvm pack to extract OCI layers for packaging. The agent streams the layer tar data back via LayerData responses.

Fields

§image_digest: String

Image digest (sha256:…).

§layer_index: usize

Layer index (0-based).

§

FlattenLayers

Merge a stack of directories into a single tar archive.

pack create --from-vm ships the machine’s image layers plus whatever the container has written since as ONE flattened layer. The merge has to apply whiteouts and opaque markers exactly as the runtime would, so it is done with a read-only overlay mount rather than a file copy.

The agent owns this rather than the host driving mount(8) over VmExec, because mount(8) rejects a lowerdir= value beyond ~255 bytes — about three OCI layer paths — while the agent can append each layer separately through the same fsconfig path the runtime container mount uses.

Fields

§lowerdirs: Vec<String>

Directories to merge, bottom -> top. Entries that are missing or empty are dropped, so a caller may include a container overlay’s upper dir without first checking whether the machine ever wrote to it.

§output: Option<String>

Guest path to write the tar archive to, or None to stream the archive straight back as DataChunk responses.

Streaming is what a large export wants. The flattened tar is as large as the image it came from, so staging it in the guest means the disk has to hold both the expanded rootfs and a second full copy of it as an archive — the export sizes that disk by guessing, and a big enough image runs it out of space.

§

BranchpointWait

Wait until the workload has declared a branchpoint, returning the ready marker’s contents (its profile lines) in data.contents.

Fields

§timeout_ms: u64

Give up after this many milliseconds.

§

BranchpointArm

Put a negotiated helper into its restore-safe loop before capture.

§

BranchpointPark

Return a parked source to its ordinary wait after capture.

§

BranchpointRelease

Release a restored clone: write the release marker for the generation recorded in its ready marker, carrying the clone’s identity, and wait for the helper to acknowledge.

Fields

§env_dotenv: Option<String>

The clone’s parameters in dotenv form, appended to the marker.

§

BranchpointActivate

Assign and release a held clone in one idempotent step: claim it with activation_token (a retry with the same token completes a partial commit; a different token is refused), install the per-clone parameters, then write the release marker.

Fields

§env_dotenv: String

Per-clone parameters, dotenv form, written to env_path.

§env_sourceable: String

The same parameters in shell-sourceable form, written to branch_env_path.

§env_path: String

Guest path of the dotenv file (under the clone’s overlay for image machines).

§branch_env_path: String

Guest path of the sourceable file.

§require_dir: Option<String>

Directory that must already exist, typically the clone’s merged overlay root; activation refuses rather than fabricating it.

§env_dir: String

Directory to create before writing the env files.

§activation_token: String

Token identifying this activation attempt.

§

BranchpointWaitWorkerReady

Wait until a released clone’s workload publishes its worker-ready token.

Fields

§token: String

The token the workload must publish; any other is a mismatch.

§timeout_ms: u64

Give up after this many milliseconds.

§

VmExec

Execute a command directly in the VM (not in a container).

This runs the command in the agent’s Alpine rootfs without any container isolation. Useful for VM-level operations and debugging.

Fields

§command: Vec<String>

Command and arguments.

§env: Vec<(String, String)>

Environment variables.

§workdir: Option<String>

Working directory in the VM.

§timeout_ms: Option<u64>

Timeout in milliseconds.

§interactive: bool

Interactive mode - stream I/O instead of buffering.

§tty: bool

Allocate a pseudo-TTY for the command.

§background: bool

Background mode - spawn and return PID immediately without waiting.

§stdin_data: Option<String>

Data to pipe to the command’s stdin.

§

Run

Run a command in an image’s rootfs.

This prepares an overlay, chroots into it, and executes the command. Returns stdout, stderr, and exit code when the command completes.

Fields

§image: String

Image reference (must be pulled first).

§command: Vec<String>

Command and arguments.

§env: Vec<(String, String)>

Environment variables.

§workdir: Option<String>

Working directory inside the rootfs.

§user: Option<String>

User inside the rootfs. If omitted, the OCI image default applies.

§mounts: Vec<(String, String, bool)>

Volume mounts to bind into the container. Each tuple is (virtiofs_tag, container_path, read_only).

§timeout_ms: Option<u64>

Timeout in milliseconds. If the command exceeds this duration, it will be killed and return exit code 124.

§interactive: bool

Interactive mode - stream I/O instead of buffering. When true, output is streamed via Stdout/Stderr responses, and stdin can be sent via the Stdin request.

§tty: bool

Allocate a pseudo-TTY for the command. Enables terminal features like colors, line editing, and signal handling.

§detached: bool

Detached mode — start the container and return immediately with the container ID. Only meaningful when persistent_overlay_id is set. Returns a Completed response with stdout containing the container ID.

§unprivileged: bool

Run the workload as an unprivileged container: restricted capabilities, read-only cgroup, and no extra tmpfs. The default (false) is “VM-grade” — since the microVM is the isolation boundary, the workload gets a full capability set and the mounts an init system needs (so any image, incl. systemd, boots). Opt in for defense-in-depth when running untrusted code.

§persistent_overlay_id: Option<String>

If set, use a persistent overlay that survives across exec sessions. The overlay is identified by this ID (typically the machine name) and reused on subsequent runs. If not set, an ephemeral overlay is created and destroyed after the run.

§stdin_data: Option<String>

Data to pipe to the command’s stdin (non-interactive runs only). The pipe is closed after writing, so the command sees EOF.

§background: bool

Spawn the container and return immediately with the crun PID. The container runs detached; stdout/stderr go to /dev/null. Incompatible with interactive and tty.

§s3_volumes: Vec<S3Volume>

S3 volumes to mount into the workload container. The agent mounts them between crun create and crun start, so the workload’s first instruction already sees them and its command is never rewritten.

§

Stdin

Send stdin data to a running interactive command.

Fields

§data: Vec<u8>

Input data to send to the command’s stdin.

§

Resize

Resize the PTY window (for TTY mode).

Fields

§cols: u16

New width in columns.

§rows: u16

New height in rows.

§

FileWrite

Write a file inside the VM in a single message.

Use only for files up to FILE_WRITE_SINGLE_SHOT_MAX. Larger files must stream via Self::FileWriteBegin + Self::FileWriteChunk to avoid exceeding MAX_FRAME_SIZE after base64 + JSON inflation.

Fields

§path: String

Absolute path in the VM filesystem.

§data: Vec<u8>

File contents.

§mode: Option<u32>

File mode (e.g., 0o644). None = default (0644).

§uid: Option<u32>

Owner uid to apply after the write. None = leave as written (root).

§gid: Option<u32>

Owner gid to apply after the write. None = leave as written (root).

§

FileWriteBegin

Open a streaming file upload session on this connection.

Must be followed by one or more Self::FileWriteChunk requests. The final chunk sets done: true to finalize. Dropping the connection (or sending any non-chunk request) before done aborts the session and leaves no partial file at path.

Sessions are per-connection — one session at a time.

Fields

§path: String

Absolute path in the VM filesystem.

§mode: Option<u32>

File mode (e.g., 0o644). None = default (0644).

§uid: Option<u32>

Owner uid to apply on finalize. None = leave as written (root).

§gid: Option<u32>

Owner gid to apply on finalize. None = leave as written (root).

§total_size: u64

Expected total size in bytes. Rejected if it exceeds FILE_TRANSFER_MAX_TOTAL. The agent uses this for an early-fail check only; the actual size written is the sum of chunk byte lengths.

§

FileWriteChunk

Append a chunk to the currently open streaming upload. If done is true, the agent fsyncs and atomically renames the staging file onto the target path.

Fields

§data: Vec<u8>

Chunk bytes. Typically FILE_WRITE_CHUNK_SIZE except for the last chunk.

§done: bool

True on the final chunk; closes and renames the staging file. False on intermediate chunks.

§

FileRead

Read a file from the VM.

Fields

§path: String

Absolute path in the VM filesystem.

§

ListDirectory

List the entries of a guest directory.

Kept separate from AgentRequest::FileRead, which streams bytes: a listing is small and structured, and a caller that has to discover what exists would otherwise guess names and read a 404 for each miss.

Fields

§path: String

Absolute directory path in the VM filesystem.

§

ArchiveDirectory

Stream a tar archive of a guest directory without creating a guest-side temporary file. Used by staged mounts to batch many small files across vsock instead of paying one virtiofs round trip per file.

Fields

§path: String

Absolute directory path in the VM filesystem.

§

PodCreate

Create (without starting) a Kubernetes pod container whose rootfs is a virtiofs-shared host directory (containerd snapshotter output) and whose process definition comes from the host’s OCI config. The agent builds its crun bundle around the shared rootfs; nothing runs until PodStart. Part of the containerd shim v2 datapath (docs/kubernetes-runtime.md).

Fields

§id: String

Container ID (containerd task id).

§rootfs_rel: String

Rootfs path relative to the sandbox’s shared virtiofs mount. The shim boots the sandbox VM with ONE shared dir and bind-mounts each container’s rootfs under it (virtiofs shares are fixed at boot, but pod containers are created afterwards), so the guest resolves this as <sandbox-share-mount>/<rootfs_rel>.

§spec_json: String

The host OCI runtime spec (config.json bytes). The agent extracts process/env/cwd/user/mounts/resources and grafts them onto its own guest bundle template; host-specific namespaces/paths are ignored.

§tty: bool

Allocate a PTY for the init process.

§

PodStart

Start a pod container created by PodCreate (or an exec process registered by PodExec), streaming its I/O on THIS connection: Started → Stdout/Stderr… → Exited. Stdin arrives via Stdin requests; PTY resize via Resize.

Fields

§id: String

Container ID.

§exec_id: Option<String>

Exec process to start instead of the init process.

§

PodExec

Register an exec process for a running pod container. Started later by PodStart { exec_id }.

Fields

§id: String

Container ID.

§exec_id: String

Exec process ID (unique within the container).

§process_json: String

OCI Process JSON (containerd’s ExecProcessRequest spec).

§tty: bool

Allocate a PTY for the exec process.

§

PodSignal

Signal a pod container’s init process (or one exec process).

Fields

§id: String

Container ID.

§exec_id: Option<String>

Exec process to signal instead of init.

§signal: u32

Signal number (SIGKILL = 9, SIGTERM = 15, …).

§all: bool

Signal the whole container process group.

§

PodPids

List PIDs inside a pod container (guest view).

Fields

§id: String

Container ID.

§

PodStats

Sample a pod container’s resource usage (guest view). The agent reads the container’s process tree from /proc (there is no per-container cgroup); the shim maps the reply into containerd’s cgroups metrics for CRI stats.

Fields

§id: String

Container ID.

§

PodDelete

Remove a pod container’s (or exec process’s) guest resources after exit: bundle, cgroup, PTY. Exit status was already streamed by PodStart’s Exited.

Fields

§id: String

Container ID.

§exec_id: Option<String>

Exec process to remove instead of the whole container.

Implementations§

Source§

impl AgentRequest

Source

pub fn log_summary(&self) -> String

A log-safe one-line summary of the request.

This string is written to the machine’s console log, which is exposed over the logs API — so it must NEVER include credential- or data-bearing fields: registry auth, env (which can carry host-resolved secrets), proxy (may embed credentials), or data (file/stdin bytes). Only the variant name plus a non-secret identifier (image) is emitted.

The match is exhaustive with no catch-all on purpose: adding a new variant forces a compile error here, so redaction is a deliberate decision rather than an accidental leak in some future request type.

Trait Implementations§

Source§

impl Clone for AgentRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AgentRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AgentRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more