After ptp_kvm initialized, there will be a new device node under /dev/ptp*. A guest userspace service, like chrony, can use this device to get host walltime, sometimes also counter cycle, which depends on the service it calls. Then this guest userspace service can use those data to do the time sync for guest. here is a rough sketch to show how kvm ptp clock works. |----------------------------| |--------------------------| | guest userspace | | host | |ioctl -> /dev/ptp%d | | | | ^ | | | | |----------------------------| | | | | | guest kernel | | | | | V (get host walltime/counter cycle) | | ptp_kvm -> hypercall - - - - - - - - - - ->hypercall service | | <- - - - - - - - - - - - | |----------------------------| |--------------------------|Quelle: Linux Kernel Mailingliste / Jianyong Wu ( https://lwn.net/Articles/830643/ )
Inhaltsverzeichnis
NTP
chronyd
- /etc/chrony/conf.d/50-local.conf
binddevice lo binddevice eth0 allow 192.168.1.0/24 allow fd42:c0de:d0c:f0::/64
Konfigurationsdatei testen:
chronyd -p
Gab es Fehler beim Start?
journalctl -eu chrony.service lsof -ac chronyd -Pi
Zeitserver von pool.ntp.org nutzen
pool.ntp.org nutzen
- /etc/chrony/sources.d/local.sources
server 0.de.pool.ntp.org iburst server 1.de.pool.ntp.org server 2.de.pool.ntp.org server 3.de.pool.ntp.org
Zeitserver der PTB nutzen
NTP-Service der Physikalisch-Technische Bundesanstalt nutzen
- /etc/chrony/sources.d/local.sources
server ptbtime1.ptb.de iburst nts server ptbtime2.ptb.de nts server ptbtime3.ptb.de nts server ptbtime4.ptb.de nts
chronyc reload sources
Warten, bis die Zeitserver verbunden sind:
watch chronyc sources -v
Chrony über chronyc steuern
Chrony Client starten und automatisch anmelden:
chronyc -a
Zeit manuell setzen:
chronyc> manual on chronyc> settime 9:30:00
Statistiken der Quellen der Netzwerkzeit anzeigen:
chronyc> sourcestats
NTP Aktivität anzeigen:
chronyc> activity
Informationen über die aktuellen Zeit-Quellen anzeigen:
chronyc> tracking
Auf die nächste Zeitsynchronization warten:
chronyc> waitsync
Die Systemzeit in (schnellen) Schritten anpassen:
chronyc> makestep
Informationen über die im Rechner eingebaute Echtzeituhr abfragen:
chronyc> rtcdata
Systemzeit in die RTC schreiben:
chronyc> trimrtc
Precision Time Protocol (PTP) im KVM Gast
Kernel Modul ptp_kvm laden:
echo ptp_kvm > /etc/modules-load.d/ptp_kvm.conf systemctl restart systemd-modules-load.service
lsmod | grep ptp_kvm
→ Kernel-Modul ptp_kvm ist geladen
→ erzeugt:
ls -l /dev/ptp*
- /etc/chrony/chrony.conf
#pool 2.debian.pool.ntp.org iburst refclock PHC /dev/ptp_kvm poll 2
chrony neu starten:
service chrony restart
Zeitquellen anzeigen:
chronyc sources -v
→ sollte nur noch PHC0 anzeigen, keine externen NTP-Quellen mehr
