Documentation
¶
Overview ¶
Package transport opens the guest↔host channel weft-init uses to stream pod status, container events, log chunks, and to receive control requests (stop, exec, restart) from weft-agent on the hypervisor host.
The transport is AF_VSOCK on Linux KVM and on Apple VZ guests (VZVirtioSocketDevice on the host side). Both expose the same kernel-level interface to the guest, so this code is the same for both backends.
Pure stdlib: we open AF_VSOCK via syscall.Socket and speak the raw socket. The weft-proto gRPC service runs over this socket; integration with grpc-go is done in cmd/weft-init wiring (a custom Dialer), not here.
Index ¶
Constants ¶
const ( VsockCIDAny = 0xffffffff // -1 VsockCIDHypervisor = 0 VsockCIDLocal = 1 VsockCIDHost = 2 )
VsockCID values reserved by the kernel.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial opens an AF_VSOCK connection to (cid, port) and wraps it in a *net.UnixConn-like net.Conn for use with grpc.WithDialer.
Typical use: Dial(VsockCIDHost, 5555) inside the guest to reach weft-agent on the hypervisor host.
func DialWithRetry ¶
DialWithRetry retries Dial up to attempts times with the given per-attempt delay. The host side of vsock isn't always ready the instant the guest finishes booting ; a few hundred ms of retry covers the gap without baking in arbitrary sleeps.
func LocalCID ¶ added in v0.2.4
func LocalCID() uint32
LocalCID reads the calling process's AF_VSOCK guest CID from the kernel via ioctl on /dev/vsock. Used by weft-microvm-agent to announce its actual CID in the GuestPodPlane Hello frame so the host can populate its podCIDs registry — closes the Apple-VZ readback gap (the host can't query Apple's framework for the assigned CID, but the guest's own kernel knows it).
Returns 0 on any error (missing /dev/vsock, ioctl failure) so non-microVM builds + older guests don't crash : the host treats a zero report as "not provided" and falls back to the v0.4.46 strict-when-known check against peer.CID().
Types ¶
This section is empty.