Skip to content

feat(move): add "vee move <vm> <target-dir>" to relocate a boot disk#39

Merged
Benehiko merged 1 commit into
mainfrom
feat/vee-move-boot-disk
Jul 18, 2026
Merged

feat(move): add "vee move <vm> <target-dir>" to relocate a boot disk#39
Benehiko merged 1 commit into
mainfrom
feat/vee-move-boot-disk

Conversation

@Benehiko

Copy link
Copy Markdown
Owner

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 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 (#38).

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.

  • -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

  • Move uses rename on the same filesystem, falling 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.
  • Rejects raw-device --boot-disk VMs (no managed image to move).
  • Refuses if a file already exists at the target, so an existing disk is never overwritten.
  • On a save-config failure the file is moved back, so config and disk never drift.

Changes

  • internal/vm/manager.go: MoveBootDisk + findManagedBootDisk / managedBootDiskAbsPath / moveFile helpers; scratchDiskPath now reuses managedBootDiskAbsPath.
  • cmd/move.go: the command with --yes / --no-start flags and directory shell completion.
  • internal/vm/move_test.go: unit tests for disk selection, path resolution, and moveFile.
  • docs: README command table + 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).
  • Verified live end-to-end on a stopped VM with a real 17 GB disk and a custom disk-os.img filename: round-trip move out and back, config path correct in both directions, VM restored to its original state.

🤖 Generated with Claude Code

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>
@Benehiko
Benehiko merged commit 0ea5960 into main Jul 18, 2026
4 checks passed
@Benehiko
Benehiko deleted the feat/vee-move-boot-disk branch July 18, 2026 00:15
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