[fix] Recover guest clock after Mac sleep - #184
Open
Fail-Safe wants to merge 1 commit into
Open
Conversation
Fail-Safe
marked this pull request as ready for review
September 10, 2026 17:08
This was referenced Sep 11, 2026
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 and behavior
When the Mac sleeps while a VM is running, the guest system clock can resume hours behind the virtual PL031 hardware clock.
systemd-timesyncdmay still report a prior synchronized state. Fresh signed Touch ID approvals are then correctly rejected as future-dated, despite successful fingerprint authentication on the host.Add a guest-only recovery service and timer. Every ten seconds of guest runtime, the helper checks the expected virtual RTC and advances system time if it is more than five seconds behind, then requests a restart of the running network time-sync service. A normally scheduled guest recovers shortly after wake; this is not an instantaneous host wake callback.
CAP_SYS_TIMEand a restricted systemd service environment.This extends the boot-time network synchronization introduced in #143. It is independent of #182 and benefits sudo, 1Password, and other guest time-sensitive services. It assumes the Mac and the virtual RTC have correct time; small offsets and backward corrections remain NTP's responsibility.
Validation
Focused tests cover a seven-hour pause, small offsets, refusal of backward corrections, wrong guest/RTC, invalid and delayed RTC samples, clock-setting failure, and unprivileged invocation.
Full
make testpassed: 110 guest tests and 242 Swift tests, plus the project contract/shell suites. The unrelated staged-QEMU lock-inheritance check was skipped because this isolated checkout has no staged runtime. No fresh factory-image build is claimed.Live reproduction established: the running guest system clock lagged approximately 7 hours 22 minutes while its PL031 RTC matched the Mac, with
NTPSynchronized=yesand timesyncd active.Existing-guest installation succeeded. The timer is active and repeated service executions complete successfully at roughly ten-second intervals. Host, guest system, and virtual RTC times match. The user confirmed Touch ID sudo worked for installation. The clocks had already converged before the new service ran, so this does not establish a live corrective step by the new helper. Subsequent live validation recorded an automatic forward correction of approximately 993 seconds (16 minutes 33 seconds) by the recovery helper. Afterward, host, guest system, and virtual RTC times matched, the timer remained active, and the user confirmed authentication was working. This establishes a real corrective step; the exact wake-to-correction latency was not measured.
GitHub CI passed for the submitted commit.