Skip to content

Port backlog from cocoon: multi-disk, VFIO passthrough, console attach, hot-NIC, virtiofs, vsock exec, logs, export/import #1

Description

@CMGS

Tracking issue for cocoon capabilities not yet ported to cocoon-macos (QEMU/macOS on x86 Linux).

Already done (context): full network port (CNI/bridge auto-TAP, same plane as cocoon CH/FC), snapshot/restore/clone (offline qcow2-internal + CoW + unique cold-boot identity), image store (cocoon cloudimg, qcow2-only), shared <state-dir>/firmware store + per-VM CoW OpenCore overlay, display-sleep fix (pmset baked).

All Linux-runtime ports should follow the *_linux.go + *_other.go build-tag split so GOOS=darwin go build ./... stays green; reuse cocoon types/utils where possible.

P0 — bypass / hardware

  • Multi-disk / data disks. Port cocoon types.DataDiskSpec + types.StorageRole (data/cow/layer/cidata) + a --data-disk flag (parsed into VMConfig.DataDisks). QEMU mapping: one extra -drive id=dN,if=none,format=…,file=… + -device virtio-blk-pci,drive=dN per disk; create + attach/detach lifecycle. Types are darwin-clean; the qcow2/format work is pure qemu-img.
  • PCI device passthrough (VFIO). Port cocoon extend/vfio (vfio.Spec/Attacher/Lister, BDF + SysfsPCIPrefix) and a vm device attach/detach surface. QEMU mapping: -device vfio-pci,host=<BDF> (host device bound to vfio-pci). Linux-only, build-tagged like the network port. Runtime-only (gone after stop/clone/restore), don't snapshot a VM holding one.

P1 — lifecycle parity

  • vm console real attach. Today it only prints a VNC 127.0.0.1:590N / SSH … hint (cmd/vm/handler.go Console). Options: add -serial (unix socket / pty) + attach via socat (note: macOS has no serial login — only OpenCore/early-boot log), and/or vm console --vnc that launches a viewer against the framebuffer. For macOS the real console is VNC + SSH, so decide whether "attach" means serial-log or VNC.
  • NIC hot-resize. cocoon vm net --nics N (add/remove NICs on a running VM). QEMU mapping: netdev_add/netdev_del + device_add/device_del virtio-net-pci over QMP, paired with cocoon network Add/Remove for the host TAP. (CH has hot-plug; QEMU does too.)
  • vm logs [-f --tail]. Capture per-VM qemu stdout/stderr to a logfile under the VM dir (currently inherits the launcher's stdout/stderr) and tail it.
  • Human-readable CLI output by default + -o json. vm list / image list / vm inspect currently print raw json.MarshalIndent as the default (machine output). Add a default table/columnar view (e.g. vm list: NAME · STATE · CPU · MEM · VNC · SSH · SERIAL · IMAGE; image list: NAME · SIZE · DIGEST · CREATED) and gate JSON behind -o json / --format json, matching cocoon's vm list -o json.
  • Streaming status / watch interface. Port cocoon's vm status [--event --format json] event stream (consumed by vk-cocoon): emit per-VM lifecycle / state-change events (created → running → stopped/exited, SSH-ready) as a line-delimited JSON stream so a consumer can watch the fleet. For cocoon-macos: a vm status --watch / --event that polls qemu liveness + the record and emits state transitions.

P2 — advanced

  • virtiofs share (vm fs attach). cocoon vhost-user-fs. QEMU mapping: virtiofsd + -chardev socket + -device vhost-user-fs-pci (+ -object memory-backend-file,share=on). Verify Tahoe has a working virtiofs driver first — may not, in which case this is blocked guest-side.
  • vsock vm exec. Run an in-guest command over vsock (cocoon uses cocoon-agent). QEMU mapping: -device vhost-vsock-pci,guest-cid=…; needs an in-guest agent on macOS (none today — SSH is the current exec path).
  • Cross-node snapshot export/import. cocoon snapshot export/import (plain tar, not OCI). For QEMU: tar the VM dir (disk overlay + OVMF_VARS + injected OpenCore + vm.json), rebase onto the same content-addressed base blob on import. Reuse cocoon snapshot/localfile envelope concept.

Notes

  • Metering / tenant accounting / network policy stay with the consumer — cocoon (and cocoon-macos) are the mechanism layer, not policy.
  • vm snapshot is intentionally offline/disk-state only: -cpu +invtsc makes the macOS guest non-migratable, so live savevm/resume-from-RAM is out (would also be an App-Store-identity risk for clones).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions