Feature/pty network repair v2 - #66
Conversation
Isolate jailed VMM processes
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
Pull request overview
This PR expands Tarit’s isolation and recovery capabilities by (1) launching jailed VMMs with optional dedicated PID + process network namespaces while passing host-owned TAP queues by fd, and (2) replacing restore-time guest network repair with a typed VMM API operation. It also updates PTY session semantics to allow reconnects while preventing concurrent attaches, with cleanup on VM stop/exit.
Changes:
- Add
--isolate-networkand--pid-namespacesupport forvmm serve, plus jailer support for creating an empty netns and launching the VMM as PID 1 in a new pidns. - Pass validated host-owned TAP queue fds from
taritd→vmm(envVMM_TAP_FDS) and validate inherited TAP fds before wiring virtio-net. - Introduce typed
repair_guest_networkusage during restore and update PTY sessions for reconnect + cleanup on VM termination.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vmm/src/main.rs | Adds CLI flags and wiring for PID namespace + empty netns in jailed serve. |
| vmm/docs/STANDALONE.md | Documents new serve flags for isolation. |
| vmm/docs/INTEGRATION.md | Documents repair_guest_network request semantics. |
| vmm/docs/BUILD-AND-API.md | Documents new serve flags and guest_network_repaired response. |
| vmm/crates/vmm-net/src/tap.rs | Adds Tap::from_inherited_fd with ioctl-based validation and nonblocking setup. |
| vmm/crates/vmm-jailer/src/lib.rs | Re-exports PID-namespace launcher API. |
| vmm/crates/vmm-jailer/src/jailer.rs | Adds isolate_network to jailer config. |
| vmm/crates/vmm-jailer/src/executor.rs | Implements netns unshare and PID-namespace launcher + liveness/PDEATHSIG wiring. |
| vmm/crates/vmm-integration/comprehensive_tests.rs | Updates jailer config construction for new field. |
| vmm/crates/vmm-integration/comprehensive_e2e.rs | Updates jailer config construction for new field. |
| vmm/crates/vmm-core/src/controller.rs | Uses inherited TAP fd mapping when present; parses VMM_TAP_FDS. |
| README.md | Updates high-level description of PID/netns isolation and TAP fd passing. |
| PRODUCTION_READINESS.md | Updates production gating text to reflect implemented isolation/repair steps. |
| orch/README.md | Updates PTY WebSocket description (single active connection + reconnect). |
| orch/docs/RESILIENCE.md | Documents PTY reconnect + cleanup expectations. |
| orch/docs/QUICKSTART.md | Updates PTY token/reconnect behavior docs. |
| orch/docs/OPERATIONS.md | Documents enabling strict jailed launch path env toggles. |
| orch/docs/ISOLATION.md | Updates production confinement gate description for PID/netns + TAP fd passing. |
| orch/docs/CONFIGURATION.md | Documents new VM jail env vars and updates production gate wording. |
| orch/docs/API.md | Updates PTY token semantics and WebSocket behavior docs. |
| orch/crates/taritd/src/supervisor.rs | Provisions network earlier, opens TAP queue for inheritance, passes VMM_TAP_FDS, adjusts cleanup, and switches restore networking to typed repair. |
| orch/crates/taritd/src/pty.rs | Adds reconnectable sessions with single active connection, plus VM-session cleanup hooks. |
| orch/crates/taritd/src/ops.rs | Ensures PTY sessions are cleaned up on stop and unexpected exits. |
| orch/crates/taritd/src/config.rs | Adds jail pidns/netns config parsing and enforces production gating. |
Suppressed comments (2)
orch/crates/taritd/src/supervisor.rs:96
- This
unsafeioctl call lacks a// SAFETY:justification. Please add one (matching the file’s existing convention) describing whyfdand theTapIfreqpointer are valid forTUNSETIFF.
if unsafe { libc::ioctl(fd.as_raw_fd(), TUNSETIFF as _, &mut ifreq) } < 0 {
orch/crates/taritd/src/supervisor.rs:107
clear_cloexec_for_childuses multipleunsafefcntlcalls without a// SAFETY:comment. Add a brief justification for why these syscalls are safe with the providedfd(and that the calls don't retain pointers).
let descriptor_flags = unsafe { libc::fcntl(fd, libc::F_GETFD) };
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| Ok(matched) |
| ))); | ||
| } | ||
| let path = std::ffi::CString::new("/dev/net/tun").expect("static TUN path"); | ||
| let raw_fd = unsafe { libc::open(path.as_ptr(), libc::O_RDWR | libc::O_CLOEXEC) }; |
| let mut launcher_liveness = [-1; 2]; | ||
| // The pipe closes atomically with launcher death and closes on any later | ||
| // exec, providing a race-free check around PR_SET_PDEATHSIG installation. | ||
| if unsafe { |
Summary
Checklist
vmm/,orch/,proto/):cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspacepass locally.jailer, review the protected-main KVM workflow after merge (or manually
dispatch it from
main). Privileged self-hosted runners never executepull-request refs.
warm-pool latency through the first successful guest exec, with explicit
median/p95/p99 and success-rate gates.
proto/only (not copied intovmm/ororch/), if this changes requests, responses, config, VM status, or PTYframes.
vmm serve --socket,ApiRequest/ApiResponse, length-prefixed JSON). If there is, it is calledout above and versioned.
unsafeblock has a// SAFETY:comment.