feat(move): add "vee move <vm> <target-dir>" to relocate a boot disk#39
Merged
Conversation
Move a VM's managed boot qcow2 disk image into another host directory (e.g. a fast NVMe) and update the persisted config to point at the new location, without changing the global storage_path. Only the boot disk image moves — vm.yaml, logs, control sockets, UEFI vars and cidata.iso stay under <storage_path>/<name>, matching how "vee create --boot-disk-path" places a new VM's disk. The command ensures the VM is shut down while its disk is moved: if it is running, vee stops it (prompting for confirmation), performs the move, then starts it again. --yes skips all prompts for scripting; --no-start leaves the VM stopped. The move uses rename on the same filesystem and falls back to copy+delete across filesystems (EXDEV). The persisted disk Path is set to the explicit destination file path so a custom basename (e.g. disk-os.img) survives — a bare directory would make Disk.AbsolutePath re-derive the generated disk-<vm>-<size>.<format> name and lose it. On a save-config failure the file is moved back so config and disk never drift. - internal/vm/manager.go: MoveBootDisk + findManagedBootDisk / managedBootDiskAbsPath / moveFile helpers; scratchDiskPath now reuses managedBootDiskAbsPath - cmd/move.go: move command with --yes / --no-start flags and dir completion - internal/vm/move_test.go: unit tests for disk selection, path resolution, moveFile - docs: README command table + site command page Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Adds
vee move <vm> <target-dir>— moves a VM's managed boot qcow2 disk image into another host directory (e.g. a fast NVMe) and updates the persisted config to point at the new location, without changing the globalstorage_path.Only the boot disk image moves —
vm.yaml, logs, control sockets, UEFI vars andcidata.isostay under<storage_path>/<name>, matching howvee create --boot-disk-pathplaces a new VM's disk (#38).The command ensures the VM is shut down while its disk is moved: if it is running,
veestops it (prompting for confirmation), performs the move, then starts it again.-y/--yes— skip all prompts (stop + restart automatically); for scripting.--no-start— leave the VM stopped after the move, even if it was running.Behaviour details
renameon the same filesystem, falling back to copy+delete across filesystems (EXDEV).Pathis set to the explicit destination file path so a custom basename (e.g.disk-os.img) survives — a bare directory would makeDisk.AbsolutePathre-derive the generateddisk-<vm>-<size>.<format>name and lose it.--boot-diskVMs (no managed image to move).Changes
internal/vm/manager.go:MoveBootDisk+findManagedBootDisk/managedBootDiskAbsPath/moveFilehelpers;scratchDiskPathnow reusesmanagedBootDiskAbsPath.cmd/move.go: the command with--yes/--no-startflags and directory shell completion.internal/vm/move_test.go: unit tests for disk selection, path resolution, andmoveFile.site/content/commands/move.md.Testing
go test ./internal/vm/... ./cmd/...— pass.golangci-lint fmt --diff && golangci-lint run— 0 issues;go build ./...— OK (pre-commit hook).disk-os.imgfilename: round-trip move out and back, config path correct in both directions, VM restored to its original state.🤖 Generated with Claude Code