mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-08-31 22:51:41 +00:00
Add pkg/host-timesync-daemon
Some hypervisors (e.g. hyperkit / xhyve) don't provide a good way to keep the VM's clock in sync with the Host's clock. NTP will usually keep the clocks together, but after a the host or VM is suspended and resumed the clocks can be suddenly too far apart for NTP to work properly. This simple daemon listens on an AF_VSOCK port and resynchronises the VM clock from the virtualised hardware clock. This is a Go conversion of original C code written by Magnus Skjegstad <magnus@skjegstad.com> Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
21
pkg/host-timesync-daemon/README.md
Normal file
21
pkg/host-timesync-daemon/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
### host-timesync-daemon
|
||||
|
||||
Some hypervisors (e.g. hyperkit / xhyve) don't provide a good way to keep
|
||||
the VM's clock in sync with the Host's clock. NTP will usually keep the
|
||||
clocks together, but after the host or VM is suspended and resumed the
|
||||
clocks can be suddenly too far apart for NTP to work properly.
|
||||
|
||||
This simple daemon listens on an AF_VSOCK port. When a connection is
|
||||
received, the daemon
|
||||
|
||||
- reads the (hypervisor's virtual) hardware clock via `RTC_RD_TIME` on
|
||||
`/dev/rtc0`
|
||||
- calls `settimeofday` to set the time in the VM
|
||||
- closes the connection
|
||||
|
||||
Note the hardware clock has only second granularity so you will still need
|
||||
NTP (or some other process) to keep the clocks closely synchronised.
|
||||
|
||||
To use this, simply connect to the AF_VSOCK port when you want the clock
|
||||
to be resynchronised. If you want to wait for completion then `read` from
|
||||
the socket -- `EOF` means the resychronisation is complete.
|
Reference in New Issue
Block a user