Skip to content

feat: vsock-first exec — prefer emberd over SSH#10

Draft
jasonhernandez wants to merge 3 commits into
aljoscha:mainfrom
jasonhernandez:feat/vsock-exec
Draft

feat: vsock-first exec — prefer emberd over SSH#10
jasonhernandez wants to merge 3 commits into
aljoscha:mainfrom
jasonhernandez:feat/vsock-exec

Conversation

@jasonhernandez
Copy link
Copy Markdown
Collaborator

Summary

When a VM has vsock enabled and emberd is running, ember exec now connects via the vsock UDS instead of SSH. Falls back to SSH when vsock is unavailable or with --ssh flag.

  • vsock-first: check vm.vsock.uds_path, try emberd, fall back to SSH
  • --ssh flag: force SSH transport (skip vsock)
  • Improved vm list: show vsock status in table output

Depends on #8 (vsock + CID allocator) and #9 (emberd daemon).

Files changed

File What
src/cli/exec.rs vsock-first exec logic, exec_vsock(), --ssh flag
src/cli/vm.rs vsock info in vm list table

Test plan

  • cargo build clean, cargo clippy --workspace clean
  • Manual: ember exec vm -- echo hello routes through vsock when available
  • Manual: ember exec --ssh vm -- echo hello forces SSH

🤖 Generated with Claude Code

jasonhernandez and others added 3 commits April 14, 2026 17:07
Add vsock device support across both Firecracker (Linux) and AVF (macOS)
backends, enabling structured host↔guest communication over a Unix domain
socket instead of SSH polling.

CLI: `ember vm create myvm --image base --vsock`
YAML config: `vsock: true`
UDS created at: `<state_dir>/vms/<name>/vsock.sock`

Linux (Firecracker):
- New `PUT /vsock` API call with guest CID and UDS path
- Firecracker natively creates the UDS and bridges to guest AF_VSOCK

macOS (AVF):
- VZVirtioSocketDeviceConfiguration added to VM config
- ember-vz implements a UDS bridge: accepts host connections on the UDS
  and proxies them to guest vsock port 1024, and accepts guest-initiated
  connections on port 1024 and bridges them back to the UDS

Both platforms expose the same UDS interface — Thermite's code path is
identical regardless of the underlying hypervisor.

Co-Authored-By: Claude <noreply@anthropic.com>
Replace hardcoded guest_cid=3 with a proper CID allocator that assigns
unique CIDs per VM, persisted in vsock/cids.json. Uses the new
StateStore::update() method for atomic read-modify-write under exclusive
flock, preventing TOCTOU races between concurrent processes.

Also validates UDS path length against macOS sun_path limit (104 bytes)
before allocating resources, and adds 6 integration tests covering CID
uniqueness, reuse, inspect output, and end-to-end UDS connectivity.
ember exec now tries vsock (emberd) first, falling back to SSH:
- Connects to the VM's vsock UDS and sends JSON-lines exec request
- No SSH dependency — works immediately after boot (emberd starts fast)
- Falls back to SSH automatically if vsock fails
- --ssh flag to force SSH path

ember vm list now shows IP address and vsock status:
  NAME         STATUS   IP             VSOCK  CPUS   MEM   DISK
  val-smoke    running  192.168.64.2   ✓      1    16 GiB  8 GiB

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant