Skip to main content

Module translator

Module translator 

Source
Expand description

Server-side 9P2000.L translator.

Accepts 9P connections (TCP for now; virtio-9P later) and translates each T-message into a Backend call. The backend is the capnp-RPC seam: the hyprstream binary crate wraps ModelClient to turn each call into a nine.capnp envelope against the model service’s fs scope, mirroring RemoteModelMount (which goes the other way: VFS → RPC).

§Server-side fid table

The translator owns a FidTable mapping 9P fid → backend fid + metadata (qtype, opened flag). This is the inverse of RemoteModelMount’s client-side fid table.

§Transport

Translator::serve runs a TCP accept loop; Translator::serve_uds runs the same loop over a Unix domain socket ([tokio::net::UnixListener]); Translator::serve_vsock runs it over a Cloud-Hypervisor hybrid-vsock host socket. All three delegate to one transport-agnostic accept loop (serve_listener) and the same per-connection Translator::serve_connection core, which operates on any AsyncRead + AsyncWrite stream. The UDS entry point is how a native Wanix workload consumes a Subject-scoped export via its p9kit.ClientFS 9P client (#506); the vsock entry point is how a kata guest dials the host VFS over native 9P (the CH ch path has no virtio-9p, so vsock is the 9P transport into the guest — #730). Translator::from_mount / serve_mount_uds / serve_mount_vsock build the translator directly from an Arc<dyn Mount> + Subject.

§Hybrid-vsock

Cloud Hypervisor exposes guest vsock as a host Unix socket that multiplexes guest ports with a connect <port>\n text handshake — the same handshake hyprstream_workers::runtime::kata_agent::hybrid_vsock_connect performs in the opposite direction (host→guest agent). Translator::serve_vsock plays the host multiplexer role: it strips and acknowledges that preamble per connection, then hands the bare stream to the shared 9P core, so hybrid-vsock reuses byte-identical connection handling with TCP and UDS and adds no new dependency. Firecracker/Dragonball raw AF_VSOCK (vsock://<cid>, mirroring AgentAddress::Vsock) is a follow-up: CH — the actual target — uses hybrid-vsock, and the raw-vsock hypervisors are not booted here.

Structs§

FidTable
Server-side fid table: 9P fid → state.
Translator
The translator: a backend plus a shared fid table.

Functions§

serve_mount_uds
Bind a Unix domain socket at path and serve mount (scoped to subject) as its 9P2000.L root until the socket errors or is closed.
serve_mount_vsock
Bind a Cloud-Hypervisor hybrid-vsock host socket at path and serve mount (scoped to subject) as its 9P2000.L root until the socket errors or is closed.
serve_mount_vsock_raw
Bind a raw (no-handshake) hybrid-vsock per-port host socket at path and serve mount (scoped to subject) as its 9P2000.L root until the socket errors or is closed.