feat(vm): data disks via --data-disk, aligned with cocoon - #6
Merged
Conversation
Contributor
Author
|
Aligned the auto-naming with cocoon: default disk names now start at |
Mirror cocoon's repeatable --data-disk key=value surface for macOS, reusing types.DataDiskSpec/ValidDataDiskName. macOS only supports name=/size= (no in-guest agent to format or mount, so fstype=/mount=/directio= are rejected) and caps at 4 disks: with no virtio-blk driver the disks ride the ich9-ahci controller's free SATA ports (0,1,3,5). Disks are created as empty qcow2, ride the same AHCI/IDE perf tuning as MacHDD, and participate in snapshot/clone.
cocoon's normalizeDataDiskSpecs auto-names from data1 (autoIdx := 1); a 0-based default was an unintended divergence in a feature whose point is alignment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds data disks to
vm run/create/clonethrough a repeatable--data-diskflag whose UX mirrors cocoon's: comma-separatedkey=valuespecs parsed into cocoon'stypes.DataDiskSpec(reused, not re-invented), validated withtypes.ValidDataDiskName.size=required,units.RAMInBytessyntax, min 16MiB (local const mirroring cocoonhypervisor.MinDataDiskSize— that package pulls in storage/metering/backend, so it is not import-worthy for one const).name=optional, defaultsdata0,data1, … ; duplicates error.qemu-img create -f qcow2 <path> <bytes>), attached with the same AHCI/IDE perf tuning as MacHDD (cache=writeback,aio=io_uring,discard=unmap,detect-zeroes=unmap), and roll back with the VM (snapshot/restore) and travel withclone(SRC's disks are reflink-copied; extra--data-diskspecs add more, name collisions with a copied disk error).Intentional macOS divergences from cocoon
fstype=/mount=/directio=are rejected. A macOS guest has no cloud-init/agent to partition, format, or mount a disk, so the disk is attached raw — the user formats it in-guest with Disk Utility /diskutil. cocoon's Linux path formats/mounts for you; here that would silently do nothing.ich9-ahcicontroller's remaining SATA ports.OpenCoreBoot(sata.2) andMacHDD(sata.4) leave exactly ports 0, 1, 3, 5 free. Enforced at parse time.Validation
gofumpt -l .clean;go build+GOOS=linux go build;golangci-lint0 issues for darwin and linux;go test -racegreen.cmd/vm/datadisk_test.go): single/multi, default names, size units, missing/too-small size, bad/dup names, rejectedfstype/mount/directio, >4 cap, clone-reserved collisions + cap.qemu/launch_test.goTestArgsDataDisks: port mapping[0,1,3,5],id/if=nonepairing, MacHDD-equal tuning, and no drives when empty.--data-diskshows in--help; below-min,fstype=, and >4 specs all error with clear messages; confirmedqemu-img create <path> <bytes>yields the expected qcow2.Stacking
Stacked on PR 1 (
fix/audit-findings); this PR targets that branch as its base. Review/merge PR 1 first.🤖 Generated with Claude Code