[codex] feat: support resizable macOS system disks - #33
Conversation
CMGS
left a comment
There was a problem hiding this comment.
useful feature and the core is right — resizeSystemDisk reuses cocoon's ReadQcow2Header + RunQemuImg, grow-only with a clear reject, and the record carries the size for clone inheritance. gates green incl asl (both GOOS), tests, gofmt.
two cleanups + one nit inline. also, non-blocking: the APFS grow daemon runs diskutil repairDisk on the whole disk (with a piped y) every boot that has free space — a heavy hammer to refresh the GPT; fine functionally, just flagging it since it's the one destructive-looking op on the boot path.
| return nil | ||
| } | ||
|
|
||
| func storageFromFlag(cmd *cobra.Command) (int64, error) { |
There was a problem hiding this comment.
reuse + consistency: datadisk.go:81 already parses sizes with units.RAMInBytes (accepts 20G). this reimplements it with a strip-trailing-i hack for a k8s-style 100Gi, so the same binary now speaks two size dialects — data disks want 20G, system disk wants 100Gi. pull one helper into utils.go (parseSize(raw) (int64, error)) and use it for both, and pick one spelling for the flag help + docs.
There was a problem hiding this comment.
measured to be precise — units.RAMInBytes natively accepts 100G, 100GB, 100GiB and rejects only bare 100Gi (invalid suffix 'gi'). so the strip-i hack exists solely for the k8s spelling. simplest: drop the hack, document --storage as 100G/100GiB (same dialect data disks already speak), one shared parseSize for both. keep Gi-tolerance only if you really want kube-style input, and then in the shared helper so data disks get it too.
| return n, nil | ||
| } | ||
|
|
||
| // resizeSystemDisk expands a newly-created overlay to target bytes. A zero |
There was a problem hiding this comment.
comment budget: 3 lines → 1. keep the WHY only:
// resizeSystemDisk grows a new overlay to target bytes (0 = keep image size); shrinking is rejected — qemu-img can't prove the guest fs survives.
|
|
||
| CPUs int `json:"cpus"` | ||
| Memory string `json:"memory"` | ||
| Storage int64 `json:"storage"` // system-disk virtual size in bytes |
There was a problem hiding this comment.
json:"storage" with no omitempty writes "storage":0 into every record that keeps the image size. add ,omitempty — zero already means 'image virtual size'.
What changed
--storageto macOS VM create/run/cloneWhy
Cloud images currently impose their original virtual disk size on every VM. Supporting safe growth makes one image reusable across multiple storage specifications without rebuilding the image.
Semantics
Validation
GOWORK=off go test ./...make fmt-check vet lintbash -n scripts/provision-macos.sh