mirror of
https://github.com/nestriness/nestri.git
synced 2026-11-14 11:22:31 +02:00
The host can now ask a box for a shell on a pseudo-terminal, the way a container runtime attaches to a container. `HostToGuest::Attach` starts the process, and the guest then dials the host on a vsock port of its own (7001) and carries the terminal's bytes over a small framed stream: data both ways, a resize, a hangup, and the exit status last. A screenful of output on the JSON-lines control channel would hold every other message in the box behind it, which is why it is not there. A failure to start is the exception, and is said on the control channel because nothing has connected to the data port yet. A shell is not a launch: it never ends the box, and the box ending ends it. It is started through the same reaper as everything else, so it cannot become the zombie that exists to be prevented. With a terminal on the other end the PTY is ordinary; without one it is put in raw mode so a command run for its output gets its bytes back unrewritten. Closing the stream hangs the shell up, process group and all. The frame codec is a pure bytes-in, frames-out module in nesprotocol with a payload cap and no skipping of unknown tags, since a length read from a guest is read across a trust boundary. No version bump: adding a message does not need one, and a guest that predates it simply never dials. The runtime stage gains strace, lsof and less, so a root shell in a box is not one that cannot trace a process. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
26 lines
853 B
Rust
26 lines
853 B
Rust
// PID 1 inside a box.
|
|
//
|
|
// A microVM has no init unless something is it, and three of the jobs are
|
|
// nobody else's: reaping whatever the workload orphans, turning a signal into
|
|
// an ordered shutdown, and being the guest end of the one channel out.
|
|
//
|
|
// It does not know what it is running. It is handed a set of shares, and then
|
|
// commands naming what to run and what an exit means, and it carries those out;
|
|
// a field that only makes sense for one kind of workload cannot reach it.
|
|
// ref(d-0033)
|
|
//
|
|
// It is also the box's only init: there is no service manager in the image, so
|
|
// the box's own services come up from a table in this binary. ref(d-0064)
|
|
|
|
pub mod attach;
|
|
pub mod filesystems;
|
|
pub mod payload;
|
|
pub mod platform;
|
|
pub mod reap;
|
|
pub mod services;
|
|
pub mod session;
|
|
pub mod shutdown;
|
|
pub mod system;
|
|
pub mod ticket;
|
|
pub mod workload;
|