Give Ctrl-] a grace period before force-stopping #45

Open
opened 2026-05-22 13:05:17 +00:00 by rc · 0 comments
Owner

Finding:
The console escape path asks the guest to stop and immediately force-stops the VM.

Problem:

  • stopVirtualMachineFromConsole closes the serial input pipe, calls vmz_request_stop, then immediately calls vmz_force_stop.
  • There is no delay, state transition, or wait for guestDidStop before force stop.

Impact:
Ctrl-] can behave like a hard power-off even when the guest could shut down cleanly. That risks data loss once disks are added and makes the "trying to halt VM lifecycle" message misleading.

Suggested fix:
Make Ctrl-] enter a stopping state: request graceful stop, wait for the graceful-stop delegate or a short timeout, and only then call force stop. Print distinct messages for graceful request, timeout, and forced stop.

Relevant code:

  • src/vmz.zig: stopVirtualMachineFromConsole.
  • lib/libvmz.swift: vmz_request_stop and vmz_force_stop.
Finding: The console escape path asks the guest to stop and immediately force-stops the VM. Problem: - `stopVirtualMachineFromConsole` closes the serial input pipe, calls `vmz_request_stop`, then immediately calls `vmz_force_stop`. - There is no delay, state transition, or wait for `guestDidStop` before force stop. Impact: Ctrl-] can behave like a hard power-off even when the guest could shut down cleanly. That risks data loss once disks are added and makes the "trying to halt VM lifecycle" message misleading. Suggested fix: Make Ctrl-] enter a stopping state: request graceful stop, wait for the graceful-stop delegate or a short timeout, and only then call force stop. Print distinct messages for graceful request, timeout, and forced stop. Relevant code: - `src/vmz.zig`: `stopVirtualMachineFromConsole`. - `lib/libvmz.swift`: `vmz_request_stop` and `vmz_force_stop`.
Sign in to join this conversation.
No labels
highprio
lowprio
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rc/vmz#45
No description provided.