fix(vmm): start a VM that is still stopping once QEMU has exited - #1414
Conversation
StopVm only has the supervisor signal QEMU and returns; QEMU exits some time later. A StartVm arriving in that window saw the VM as running, skipped the launch and still returned success, so the guest stayed down until the exited-VM check restarted it about 20s later. StopVm stays asynchronous. start_vm now recognises a process that has been told to stop (started == false) but is still running, waits under the launch lock for it to exit (bounded at 60s) and then launches it. If QEMU has not exited by then, the start fails with an error instead of silently doing nothing. The TPM launcher's graceful-stop poll uses the same wait_for_exit helper. Signed-off-by: Kevin Wang <wy721@qq.com>
66ca977 to
066ed86
Compare
|
Physical TDX (tdxlab) check of this revision (
In round 2 the new QEMU booted, then the guest's |
|
The full physical-TDX sweep of |
Problem
StopVmreturns as soon as the supervisor has been told to kill QEMU; QEMU exits some time later. AStartVmarriving in that window saw the VM as running, skipped the launch and still returned success. The guest then stayed down until the exited-VM check restarted it about 20s later.Fix
StopVmstays asynchronous.start_vmnow recognises a process that has been told to stop (started == false) but is still running, waits under the launch lock for it to exit (bounded at 60s), and then launches it. If QEMU has not exited by then, the start fails withVM is still stopping, try again once it has exitedinstead of silently doing nothing. The TPM launcher's graceful-stop poll uses the samewait_for_exithelper.Verification
cargo test -p dstack-vmm -p supervisorpasses. The new test uses a fake supervisor whose process keeps running for three polls after the stop; it fails without the fix.cargo clippy -p dstack-vmm -p supervisor --all-targets -- -D warningsis clean.