Skip to content

macOS guests 4/6: snapshots, standby and stopped forks - #506

Draft
chruffins wants to merge 1 commit into
feat/macos-guest-servicefrom
feat/macos-snapshots
Draft

chruffins wants to merge 1 commit into
feat/macos-guest-servicefrom
feat/macos-snapshots

Conversation

@chruffins

@chruffins chruffins commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PR 4 of 6: stopped snapshots, same-instance standby/restore, and cold forks of stopped instances or snapshots. Base: #500.

  • Create stopped disk snapshots only after a confirmed graceful stop. Restore requires the same instance, machine identifier, hardware model and MAC; stage swaps outside the guests directory with rollback and crash recovery.
  • Support experimental same-instance memory standby/restore. Memory snapshots and independent memory forks remain unsupported.
  • Fork a gracefully stopped instance or stopped snapshot only with an enabled guest agent. Copy disk and auxiliary storage, generate a fresh VZ machine identifier and a fresh MAC when networking is enabled, then rekey SSH host keys on first start. A failed rekey stops the VM and is retried on the next start.
  • Snapshot forks default to Stopped; Running cold-boots through the same identity/rekey path. Clear inherited readiness markers and reset macOS clone phase accounting. Reject incompatible target backends before copying files.
  • Recheck clone MACs at serialized metadata admission. Use metadata-only name checks for NAT-backed macOS forks; leave Linux network-registry checks unchanged.
  • Persistently clear graceful-stop receipts before boot; enforce identity/MAC admission during restore; use uncancelable teardown for failed rekeys.

Validation

  • All six layers pass build, targeted vet, relevant instance regression tests and targeted API tests. Relevant tests also pass with -race.
  • Darwin/arm64 source and test type-checks pass using a cgo-stub checker; this is not native execution.
  • Admission tests cover stopped kind, graceful receipt, enabled agent and incompatible backend rejection before copying. Existing staged-swap tests cover rollback and interrupted-swap recovery.
  • Added a Darwin metadata test for two independent snapshot forks: distinct machine IDs/MACs, readiness reset, clean phase accounting, duplicate-name rejection, backend configuration validation, auxiliary-storage copying and disk-write independence. This test has been type-checked, not run natively here; it does not boot a guest.
  • The new stopped-snapshot fork path has not been exercised against a live macOS guest here.

Limitations

Saved-state restore is experimental and may fail; failure leaves the instance in Standby. Hostname, account credentials and application-specific identities are outside the SSH-key rekey contract. Memory snapshot forks and cross-host saved-state portability remain unsupported.

Stack

#498 runtime and lifecycle → #499 OCI images → #500 guest service → #506 snapshots and stopped forks → #503 image builds → #501 guest-port forwarding.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8a79efe. Configure here.

Comment thread lib/instances/start.go Outdated
stored.ProgramStartedAt = nil
stored.GuestAgentReadyAt = nil
// A crash after a graceful stop must not leave a stale graceful receipt behind.
stored.StopGraceful = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale graceful receipt after start

Medium Severity

StopGraceful is cleared only in memory at the start of startInstance and persisted after the VM is already running. A crash or a failed saveMetadata in that window leaves the prior graceful receipt on disk, so a later stopped snapshot can capture a disk that is no longer consistent.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a79efe. Configure here.

@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 8a79efe to 10c8f44 Compare October 11, 2026 18:11
@chruffins chruffins changed the title PR6 (draft): macOS stopped snapshots and same-instance restore macOS guests 6/6: stopped snapshots and same-instance restore Oct 11, 2026
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 10c8f44 to 0bc847d Compare October 11, 2026 21:45
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 0bc847d to bcd99d3 Compare October 11, 2026 21:49
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from bcd99d3 to 0aedf45 Compare October 11, 2026 22:04
@chruffins
chruffins force-pushed the feat/macos-snapshots branch 2 times, most recently from 2e09087 to 28fb9ac Compare October 12, 2026 01:29
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 28fb9ac to 17c3d4d Compare October 12, 2026 01:34
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 17c3d4d to 53b1a79 Compare October 12, 2026 18:32
@chruffins chruffins changed the title macOS guests 6/6: stopped snapshots and same-instance restore macOS guests 6/6: stopped snapshots, same-instance restore and stopped clones Oct 12, 2026
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 53b1a79 to fa7578a Compare October 12, 2026 22:06
@chruffins chruffins changed the title macOS guests 6/6: stopped snapshots, same-instance restore and stopped clones macOS guests 6/6: stopped snapshots, same-instance standby and restore, and stopped clones Oct 12, 2026
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from fa7578a to bb25ff9 Compare October 12, 2026 22:34
@chruffins
chruffins force-pushed the feat/macos-snapshots branch 2 times, most recently from 0143542 to d58bc88 Compare October 13, 2026 00:05
@chruffins
chruffins added this pull request to stack #508 October 13, 2026 00:06
@chruffins chruffins changed the title macOS guests 6/6: stopped snapshots, same-instance standby and restore, and stopped clones macOS guests 4/6: stopped snapshots, same-instance standby and restore, and stopped clones Oct 13, 2026
…e, and stopped clones

Stopped snapshots after a graceful stop, same-instance restore through a staged
disk swap, experimental same-instance standby, and clones from a stopped source
with a fresh machine identifier, MAC and SSH host keys.
@chruffins
chruffins force-pushed the feat/macos-snapshots branch from 8dcb528 to de4d869 Compare October 13, 2026 19:12
@chruffins chruffins changed the title macOS guests 4/6: stopped snapshots, same-instance standby and restore, and stopped clones macOS guests 4/6: snapshots, standby and stopped forks Oct 13, 2026

This branch has not been deployed

No deployments
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