Repository navigation
vm: bring the docker tunnel up whenever the VM is awake - #403
mobileoverlord wants to merge 1 commit into
Conversation
The supervisor killed the docker tunnel on idle pause and brought it back only for a user-lane docker connection. A VM resumed any other way (a TCP-lane connection, or the desktop's own QMP cont) stayed without one, and the idle-exempt docker lane the desktop's containers view uses failed every retry until the next build. That lane now starts the tunnel in the background when it finds it down and the VM running, and still never wakes the VM. Before trusting its `paused` flag it asks QEMU, so a VM someone else resumed is seen as awake and gets its idle window again. A tunnel started just before a pause is killed once the VM is stopped.
There was a problem hiding this comment.
🟡 Changes recommended
A critical resume race lets the idle watcher act on a stale timestamp and immediately stop the VM because pause() does not recheck the idle deadline while holding qmp_lock.
1 open issue
What changed in this PR
This PR lets the VM supervisor restore the Docker tunnel when the idle-exempt lane encounters an awake VM without one, without waking paused VMs.
Changes:
- Starts tunnel recovery in the background so callers can retry.
- Detects external VM resumes, refreshes the idle clock, and adds safeguards against tunnel startup racing with pause.
- Adds fake-QMP tests for externally resumed and still-paused VMs.
| File | Description |
|---|---|
src/utils/vm/supervisor.rs |
Adds tunnel recovery, paused-state reconciliation, pause safeguards, and unit tests. |
Review effort: Balanced
| self.paused.store(false, Ordering::Relaxed); | ||
| self.touch(); |
There was a problem hiding this comment.
Fixed in 3fd5d794: pause() now rechecks idleness (no open connections, threshold elapsed) after taking qmp_lock, before touching the tunnel or QEMU, and returns whether it paused. sync_paused also refreshes the clock before clearing paused, so the watcher never sees an awake VM with its pre-pause timestamp. Test: a_pause_queued_before_new_activity_does_not_stop_the_vm.
There was a problem hiding this comment.
error: The PR head is still 7052a1cb, and GitHub cannot resolve the cited fix commit 3fd5d794. At this head, sync_paused() still clears paused before touch(), and pause() does not recheck active connections or the idle deadline after acquiring qmp_lock. An idle-watcher pause queued with the old timestamp can therefore stop a freshly resumed VM. Push the cited fix so both the timestamp ordering and the check inside pause() are included in this PR.

Why
The VM supervisor kills the docker SSH tunnel on idle pause and only brings it back from a user-lane docker connection. When the VM is resumed any other way (a TCP-lane connection such as
vm shell, or the desktop waking a hibernated VM with its own QMPcont), the tunnel stays down. The idle-exempt docker lane (docker-stream.sock), which the desktop's containers view uses, then fails every retry withdocker tunnel not up (VM paused or still booting)until the next build. Separately, after a desktopcontthe supervisor'spausedflag staystrue, so it never idle-pauses that VM again.What
All in
src/utils/vm/supervisor.rs:ensure_tunnel()in the background and still fails that attempt fast, so the caller's next retry succeeds. It never wakes the VM; hibernation is unchanged.paused, the infra lane asks QEMU (query-status). A VM resumed outside the supervisor is marked awake and its idle clock restarts, so it pauses again on schedule.ensure_tunnel()refuses while paused, andpause()kills the tunnel once more after QMPstop, in case a background start raced it.Testing
cargo fmt --check,cargo clippy --all-targets -D warnings, fullcargo test.docker-stream.sock/_ping:cont: "VM was resumed outside the supervisor", tunnel up, then the idle pause fires again 60 s later.Not in scope: idle pause while a USB/IP device is attached to the guest.