Skip to content

[codex] fix: assign unique hostname to macOS VMs - #32

Draft
czmDeRepository wants to merge 1 commit into
cocoonstack:masterfrom
czmDeRepository:codex/macos-unique-hostname
Draft

[codex] fix: assign unique hostname to macOS VMs#32
czmDeRepository wants to merge 1 commit into
cocoonstack:masterfrom
czmDeRepository:codex/macos-unique-hostname

Conversation

@czmDeRepository

Copy link
Copy Markdown
Contributor

What changed

Install a small persistent LaunchDaemon in provisioned macOS images that derives ComputerName, LocalHostName, and HostName from the VM's SMBIOS UUID.

Why

Cloned macOS disks retain the source machine name. Multiple guests then advertise the same mDNS name and macOS resolves the collision by renaming hosts unpredictably. VMs created with --random-smbios already have a stable unique UUID, which is a suitable source for an idempotent per-VM hostname.

Validation

  • GOWORK=off go test ./...
  • make fmt-check vet lint
  • bash -n scripts/provision-macos.sh

@CMGS CMGS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

image/script only, bash -n passes. the design is sound — persistent daemon deriving all three host names from the first 8 hex of IOPlatformUUID is idempotent and self-healing. two notes, neither blocking:

  1. only effective with --random-smbios. without it every guest shares the golden's SMBIOS UUID, so they all become the same cocoon-mac-<8> — the collision is renamed, not removed. worth one line in the section comment so it isn't read as a universal fix.
  2. reverse-dns label drift (see inline).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>com.cocoon.set-hostname</string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

label prefix is inconsistent across the daemons: existing com.cocoon.firstboot, this one com.cocoon.set-hostname, and #33 adds io.cocoon.resize-system-disk. pick one reverse-dns prefix for all three so they group predictably in launchctl.

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.

2 participants