Expand description
Protocol types for smolvm host-guest communication.
This crate defines the wire protocol for vsock communication between the smolvm host and the guest agent (smolvm-agent).
§Protocol Overview
Communication uses JSON-encoded messages over vsock. Each message is prefixed with a 4-byte big-endian length header.
+----------------+-------------------+
| Length (4 BE) | JSON payload |
+----------------+-------------------+Re-exports§
pub use image_ref::image_repo;pub use image_ref::normalize_image_ref;pub use secrets::SecretRef;pub use secrets::SecretSourceKind;
Modules§
- base64_
bytes - Serde helper for encoding
Vec<u8>as a base64 string in JSON. - cid
- vsock CID constants.
- error_
codes - Error codes for agent responses.
- forkpoint
- Stable guest paths used to coordinate a live fork.
- fsnotify_
mask - fsnotify event masks, mirroring the kernel’s
FS_*bits ininclude/linux/fsnotify_backend.h. Shared by the host watcher (which maps a host filesystem event to one of these) and the guest agent (which forwards the raw bits to/proc/smolvm-fsnotify). Only the subset relevant to file-watching tools is defined. - guest_
env - Shared environment-variable contract between the host launcher and guest agent.
- image_
ref - Image reference canonicalization.
- ports
- Well-known vsock ports.
- publish_
socket - Shared spec for user-published host↔guest Unix-socket bridges.
- retry
- Retry utilities for transient failure recovery.
- secrets
- Secret reference types shared across smolvm surfaces.
Structs§
- Envelope
- Envelope that wraps any message with an optional trace ID for correlation.
- FsNotify
Event - A single host-originated filesystem change to replay into the guest.
- Image
Info - Image information returned by Query/ListImages.
- Overlay
Info - Overlay preparation result.
- Registry
Auth - Registry authentication credentials for pulling images.
- Storage
Status - Storage status information.
Enums§
- Agent
Request - Agent request types (for image management and OCI operations).
- Agent
Response - Agent response types.
- Decode
Error - Error decoding a wire message.
- Guest
Message - Messages from workload VM to host.
- Host
Message - Messages from host to workload VM.
Constants§
- AGENT_
READY_ MARKER - Filename of the virtiofs-visible marker the agent creates when it is ready to accept vsock connections.
- FILE_
TRANSFER_ MAX_ TOTAL - Hard ceiling on a single file transfer in either direction.
- FILE_
WRITE_ CHUNK_ SIZE - Payload bytes per streaming upload chunk. Deliberately small —
equal to
FILE_WRITE_SINGLE_SHOT_MAX— so each chunk’s encoded frame (~1.4 MB) fits inside typical kernel Unix-socket send buffers (SO_SNDBUFdefaults on the order of 200–256 KiB but can grow). Larger chunks would forcewrite_allto spin waiting for the agent to drain, and any latency spike trips the 10 s write timeout withEAGAIN— exactly the failure David reproduced before this fix landed. - FILE_
WRITE_ SINGLE_ SHOT_ MAX - Files at or below this size are written with a single
FileWritemessage. Larger files must stream viaFileWriteBegin+FileWriteChunkso no single frame approachesMAX_FRAME_SIZE(base64 + JSON inflation is ~1.4x). - LAYER_
CHUNK_ SIZE - Chunk size for streaming layer data (~16 MB raw, ~21 MB as base64 JSON).
- MAX_
FRAME_ SIZE - Maximum frame size (32 MB - layer exports use chunked streaming).
- PROTOCOL_
VERSION - Protocol version.
- ROSETTA_
GUEST_ PATH - Guest mount point for the Rosetta 2 Linux runtime. The ptrace wrapper execs
<ROSETTA_GUEST_PATH>/rosetta(the translator), so this path is baked into both the wrapper and thebinfmt_miscregistration. - ROSETTA_
TAG - virtiofs tag under which the host exposes the Rosetta 2 Linux runtime to the
guest. Shared host↔guest so the launcher’s
krun_add_virtiofstag and the guest agent’smount -t virtiofssource can’t drift apart.
Functions§
- decode_
message - Decode a message from wire format.
- encode_
message - Encode a message to wire format (length-prefixed JSON).