Hyper.Node.FireVMM.Agent.Relay (Hyper v0.1.0)

Copy Markdown View Source

Per-VM gRPC relay: listens on a host Unix-domain socket and for each inbound connection performs the Firecracker vsock CONNECT/OK handshake via RelayDialer, then pipes bytes bidirectionally until either side closes.

Process topology:

  • The GenServer owns the listen socket and spawns a linked acceptor process via handle_continue. The acceptor blocks on :socket.accept without blocking the GenServer itself.
  • Each accepted connection spawns an unlinked connection process that calls RelayDialer.dial/3 then spawns two linked+monitored pipe workers (one per direction). The link ensures a connection handler death reaps both workers; the monitor lets the handler react to a worker's normal end and close both sockets cleanly. When either worker ends, the handler unlinks the sibling before killing it so the resulting :killed exit does not cascade back to the handler via the link.
  • terminate/2 closes the listen socket (which causes the acceptor to exit on its next accept call) and removes the socket file so a subsequent start_link with the same path can rebind.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

@spec child_spec(%{vm_id: term(), vsock_uds: Path.t(), listen_path: Path.t()}) ::
  Supervisor.child_spec()

Returns a specification to start this module under a supervisor.

See Supervisor.

listen_path(server)

@spec listen_path(GenServer.server()) :: Path.t()

start_link(opts)

@spec start_link(%{
  :vm_id => term(),
  :vsock_uds => Path.t(),
  :listen_path => Path.t(),
  optional(:name) => GenServer.name()
}) :: GenServer.on_start()