Page MenuHomeFreeBSD

vmm: save the current time of the RTC in a snapshot
Needs ReviewPublic

Authored by wanpengqian_gmail.com on Fri, Oct 2, 5:57 AM.
Tags
None
Referenced Files
F174440147: D60227.id188368.diff
Sat, Oct 3, 5:55 AM
F174429489: D60227.diff
Sat, Oct 3, 3:42 AM
F174364939: D60227.diff
Fri, Oct 2, 5:19 PM
F174341035: D60227.id188368.diff
Fri, Oct 2, 1:16 PM
Subscribers

Details

Reviewers
jhb
markj
Group Reviewers
bhyve
Summary

vrtc_snapshot() saved base_rtctime, the time the RTC had at
base_uptime. That pair is brought up to date when the guest reads or
writes the RTC and, once a second, while the alarm or the update
interrupt is enabled. A guest that does neither for hours has a base
that is hours old. A restore sets base_uptime to the uptime of the
restore, so the restored RTC was late by the age of the base.

Save the time the RTC shows when the snapshot is taken. The format of
the snapshot does not change.

Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev

Test Plan

main (f958aa7e7) with WITH_BHYVE_SNAPSHOT, FreeBSD 16.0-CURRENT guest (it reads the RTC when it boots and then leaves it alone; LAPIC event timer). The guest idles for 5 minutes, then bhyvectl --suspend, 30 seconds later bhyve -r, and bhyvectl --get-rtc-time 2 seconds after that:

host timeRTC
before: guest up05:39:1105:39:10
before: at the suspend05:44:1105:44:10
before: after the restore05:44:4805:38:52
after: guest up05:45:3305:45:33
after: at the suspend05:50:3305:50:33
after: after the restore05:51:1005:50:36

Before the change the restored RTC is back at the time of the guest's last access plus the seconds since the restore; after it, it goes on from the time of the suspend.

The time during which the guest was suspended is not added, before or after: that is a matter of policy and left alone here.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77603
Build 74486: arc lint + arc unit