Delete the dead ISO-eject step from provision-vm-from-host #19
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
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#19
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?
Delete a two-line ISO-eject step in the host-side VM provisioning script that cannot affect the definition
virsh startreads, and correct a stale comment above thenixos-anywherecall that documents a flag the invocation does not pass.Primary goals:
scripts/provision-vm-from-host:113-114, which mutates only the live domain that the very next line destroys, so it can never reach the persistent XML that the subsequentvirsh startreads.2>/dev/nulland via an[[ ... ]] && cmd || truechain, which is the anti-patternmemory/shell.mdnames and a violation ofarchitecture.mdprinciple 11 (fail loud, never fall back silently).awk '/cdrom/ {print $3}'matches the whole line rather than the Device column, so a source path containing the substringcdromyields a disk row's target instead.scripts/provision-vm-from-host:101describes a--no-rebootflag that the invocation immediately below it does not pass.destroy/sleep 1/startsequence atscripts/provision-vm-from-host:115-117stays untouched; it is what actually boots the VM off the installed disk.The eject cannot reach the definition that matters
The two lines under the
# Eject ISO and hard restart so UEFI boots from installed diskcomment atscripts/provision-vm-from-host:111are:change-mediais passed neither--confignor--live, so against a running QEMU domain it affects the live domain only. That live domain is destroyed on the very next line,scripts/provision-vm-from-host:115. The eject therefore never touches the persistent definition, and the persistent definition is exactly whatvirsh startatscripts/provision-vm-from-host:117boots from. What actually makes the VM boot off disk is thatvirt-install --cdromatscripts/new-vm:125attaches the ISO for the install boot but leaves the media path empty in the persistent definition, so the destroy/start pair brings the domain back with no ISO in the drive. This is confirmed empirically on the host:virsh dumpxml --inactivefor a provisioned dev VM shows the cdrom disk with no<source>element at all.The failure is swallowed twice
2>/dev/nulldiscards any diagnostic, and the[[ -n "$CDROM" ]] && ... || truechain guarantees exit 0 regardless of whatchange-mediadoes. A step that has never worked has also never been able to say so.memory/shell.mdrecords that ina && bonly the final command's failure aborts underset -e, which is what makes this chain a permanent pass.The awk pattern matches the wrong column
domblklist --detailsprints the columnsType Device Target Source. The test fixture attests/provision-vm-from-host.sh:102-103stubs exactly that shape, emittingfile cdrom sda /tmp/installer.iso. The pattern/cdrom/is unanchored across the whole record, not restricted to the Device field, so a disk whose Source path happens to containcdrom— an ISO library directory, a pool named for it — would match and hand back that disk's Target. Forchange-media --ejectthis is harmless in practice, but it is a live foot-gun the moment anyone converts the step into something destructive such asdetach-disk. Deleting the step removes the foot-gun along with the dead code.Stale
--no-rebootcommentscripts/provision-vm-from-host:101reads# --no-reboot: we eject the ISO before rebooting; otherwise the VM boots back into installer, but thenixos-anywhereinvocation directly beneath it passes no--no-reboot. It relies on--phases disko,installatscripts/provision-vm-from-host:105simply omitting the reboot phase. The comment should describe the phase selection that is actually in force, and should stop referring to an eject that will no longer exist.Scope
In scope: deleting
scripts/provision-vm-from-host:113-114, adjusting the surrounding comment and echo atscripts/provision-vm-from-host:111-112so they describe the destroy/start restart rather than an eject, and rewriting the stale comment atscripts/provision-vm-from-host:101. Thedestroy/sleep 1/startsequence is deliberately left alone.Explicitly out of scope, and not to be re-added later: a
virsh detach-diskto remove the leftover CD-ROM device from the persistent definition. The device that remains is an empty drive with no media path — it is cosmetic, it carries no boot risk because there is nothing to boot, and it is not a host-to-guest data path. Adding a detach would arm the wrong-column targeting problem described above against a genuinely destructive command in order to solve a non-problem.architecture.mdprinciple 14 says gates that cannot verify quality get deleted rather than elaborated, and principle 15 puts minimalism first; both point at deletion rather than a replacement step.Also out of scope: any change to the test suite's behavior contract.
tests/provision-vm-from-host.shasserts onlygrep -q 'start alpha-dev'against the virsh log attests/provision-vm-from-host.sh:355; nothing asserts the eject, so the suite should pass unchanged. Thedomblklistcase in the virsh stub becomes unreachable and may be left or trimmed with the script change.Residual risk: R1. The change is confined to one host-side provisioning script and deletes only code that provably has no effect on the persistent domain definition; it touches no key material, no secrets, no inventory, and no guest-facing state. Blast radius is a single host command sequence run by a human at the terminal, and any error surfaces immediately and loudly at the next
virsh startduring a provisioning run, which is itself a destructive-and-repeatable operation on a disposable VM. Rollback is a one-commit revert.