new-vm --replace: graceful shutdown by default, hard kill behind a flag #72
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/nexus#72
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Make replacing a running guest safe for a stateful service VM:
--replaceshuts the guest down cleanly and waits, and the immediatevirsh destroyit does today moves behind an explicit flag.Primary goals:
--replacesendsvirsh shutdown, waits for the domain to reachshut off, then undefines and recreates as today.destroyon its own.cli-design.md(--forceor--hard), keeps today's immediatevirsh destroy.Current state and specifics
scripts/new-vm:210-212on--replace:virsh destroy(silenced) thenvirsh undefine --nvram --storage vda;scripts/new-vm:217-218does the same for a stale domain;scripts/new-vm:137suggests the samedestroy; undefinepair by hand when the domain exists without--replace.provision-vmpasses--replacethrough tonew-vmand reattaches a declared data disk after the install (scripts/provision-vm:150-157), so the disk survives but whatever was mid-write on it when the guest was killed does not.For a guest running a pruned Bitcoin node that is the difference between a resumed sync and a full redownload: a hard kill mid-sync can leave the chainstate inconsistent, and a pruned node cannot reindex because the blocks it would need are gone. The node's unit allows ten minutes to flush on stop, so the wait ceiling must exceed that; a default of fifteen minutes, overridable by a flag or environment variable, covers it.
No guest-side change is needed: NixOS guests power off on the ACPI button
virsh shutdownsends.Validation
new-vm --replace <name>logs the shutdown, the domain reachesshut offbefore the undefine, and the data disk's filesystem mounts clean on the new machine.tests/new-vm.shcovers the three paths.Scope
In scope:
scripts/new-vm, its usage text,tests/new-vm.sh, and the by-hand suggestion atscripts/new-vm:137. The same treatment forrebuild-vm, if it has a kill path, is a follow-up once this lands.