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::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.
- guest_
env - Shared environment-variable contract between the host launcher and guest agent.
- image_
ref - Image reference canonicalization.
- ports
- Well-known vsock ports.
- 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.
- 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.
Functions§
- decode_
message - Decode a message from wire format.
- encode_
message - Encode a message to wire format (length-prefixed JSON).