fix: restore --force relaunches under the launch-scoped VNC contract - #36
Merged
Conversation
The record never persists VNCPass, but restore --force kept VNCDisp from the terminated QEMU and relaunched with it: a CNI VM then failed requireCNIVNCPassword after its disks were already reverted, leaving a stale PID on disk, and a non-CNI VM came back with VNC listening without a password. Stop already clears both and stops the VNC proxy; restore now does the same before launch.
…ch owns the stale VNC proxy A restore that failed after terminating QEMU (a missing tag on one disk, a failed apply, a failed relaunch) left vm.json with the dead PID and the old display; the cleared record is saved as soon as the VM is down. A previous launch's detached VNC proxy survived QEMU's exit, so a relaunch without --vnc (the supervisor's cold relaunch after a guest reboot) left 590n listening; launch now stops any proxy before it boots, which also covers restore.
restore's snapshot validation and apply can fail after QEMU is gone and before launch runs, leaving the detached proxy listening until the next start or stop. Terminate and proxy stop are one step, as in Stop.
…unch already did Stop and restore both wrote "stop the proxy, clear PID and VNC, save"; saveStopped owns that tail. launch's error branch stopped a proxy that its own unconditional stop a few lines above had already removed.
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.
Problem
vm restore --forceon a running VM terminates QEMU, reverts the disks, then callslaunchwith the loaded record.VNCPassis never persisted (json:"-"), butVNCDispis, so the relaunch carried a display number with an empty password:requireCNIVNCPasswordrefused the launch after the disks were already reverted, andsaveRecwas never reached, so the record kept the dead PID.127.0.0.1:590nand no password, where the previous incarnation required one.Stopalready encodes the contract (r.PID, r.VNCDisp, r.VNCPass = 0, -1, ""plusstopVNCProxy);Startre-enables VNC only from its own flags. Restore was the one launch path that did not follow it.Change
Restore's
wasRunningbranch stops the VNC proxy and clears the three launch-scoped fields before relaunching, exactly asStopdoes.Evidence
GOWORK=off make lint(linux + darwin): 0 issues ×2.make fmt-check: clean.asl ./...both GOOS: clean.go test -race ./...: green. The restore path has no unit harness (it drives a real QEMU); the change mirrors the stop path line for line.