Skip to content

Commit

Permalink
Add support for ptp_kvm to coreos-platform-chrony system-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
karelvanhecke committed Mar 10, 2023
1 parent 413b7db commit 4e9b385
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ConditionKernelCommandLine=|ignition.platform.id=azurestack
ConditionKernelCommandLine=|ignition.platform.id=azure
ConditionKernelCommandLine=|ignition.platform.id=aws
ConditionKernelCommandLine=|ignition.platform.id=gcp
ConditionKernelCommandLine=|ignition.platform.id=qemu
Before=NetworkManager.service
Before=chronyd.service

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if ! cmp {/usr,}/etc/chrony.conf >/dev/null; then
exit 0
fi

mkdir -p /run/coreos
confpath=/run/coreos/platform-chrony.conf
altenvfilepath=/run/coreos/sysconfig-chrony
cmdline=( $(</proc/cmdline) )
Expand All @@ -34,6 +33,14 @@ cmdline_arg() {
}
platform=$(cmdline_arg ignition.platform.id)

# Exit early if the ptp_kvm module can't be loaded for the qemu platform
if [[ ${platform} == "qemu" ]]; then
modprobe -q ptp_kvm || exit 0
fi

# Create /run/coreos
mkdir -p /run/coreos

# If not set already (by host customization or this script), set
# PEERNTP=no so that DHCP-provided NTP servers are not added to chrony.
# By doing this we assume the better NTP server choice is the
Expand Down Expand Up @@ -77,6 +84,11 @@ case "${platform}" in
echo '# and https://cloud.google.com/compute/docs/images/configuring-imported-images'
echo 'server metadata.google.internal prefer iburst'
) >> "${confpath}" ;;
qemu)
sed -i s,'^#pool,pool,' "${confpath}"
(echo '# KVM virtual PHC'
echo 'refclock PHC /dev/ptp0 poll 2'
) >> "${confpath}" ;;
*) echo "should not be reached" 1>&2; exit 1 ;;
esac
# Policy doesn't allow chronyd to read run_t
Expand Down
6 changes: 5 additions & 1 deletion tests/kola/ntp/chrony/coreos-platform-chrony-generator
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
## kola:
## exclusive: false
## platforms: "aws azure gce"
## platforms: "aws azure gce qemu"
#
# Test the coreos-platform-chrony generator.

Expand All @@ -14,5 +14,9 @@ case "${platform}" in
aws) chronyc sources |grep '169.254.169.123'; echo "ok chrony aws" ;;
azure) chronyc sources |grep 'PHC'; echo "ok chrony azure" ;;
gcp) chronyc sources | grep '169.254.169.254'; echo "ok chrony gcp" ;;
qemu)
if [[ -f /run/coreos/sysconfig-chrony ]]; then
chronyc sources | grep 'PHC0'; echo "ok chrony qemu"
fi ;;
*) echo "unhandled platform ${platform} ?"; exit 1 ;;
esac

0 comments on commit 4e9b385

Please sign in to comment.