diff --git a/overlay.d/20platform-chrony/usr/lib/systemd/system/coreos-platform-chrony-config.service b/overlay.d/20platform-chrony/usr/lib/systemd/system/coreos-platform-chrony-config.service index f64f84da58..6a1bce8823 100644 --- a/overlay.d/20platform-chrony/usr/lib/systemd/system/coreos-platform-chrony-config.service +++ b/overlay.d/20platform-chrony/usr/lib/systemd/system/coreos-platform-chrony-config.service @@ -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 diff --git a/overlay.d/20platform-chrony/usr/libexec/coreos-platform-chrony-config b/overlay.d/20platform-chrony/usr/libexec/coreos-platform-chrony-config index 41e6c0b951..b91f880bac 100755 --- a/overlay.d/20platform-chrony/usr/libexec/coreos-platform-chrony-config +++ b/overlay.d/20platform-chrony/usr/libexec/coreos-platform-chrony-config @@ -23,9 +23,6 @@ if ! cmp {/usr,}/etc/sysconfig/chronyd >/dev/null; then exit 0 fi -mkdir -p /run/coreos -confpath=/run/coreos/platform-chrony.conf -altenvfilepath=/run/coreos/sysconfig-chrony cmdline=( $(> /etc/sysconfig/network + # Historically on QEMU, we haven't been disabling PEERNTP. Let's keep doing + # that even if we have ptp_kvm. chrony will just use the NTP servers as + # additional sources. + if [[ ${platform} != "qemu" ]]; then + cat <> /etc/sysconfig/network # PEERNTP=no is automatically added by default when a platform-provided time # source is available, but this behavior may be overridden through an Ignition # config specifying PEERNTP=yes. See https://github.com/coreos/fedora-coreos-config/pull/412. PEERNTP=no EOF + fi fi (echo "# Generated by $self - do not edit directly" @@ -81,6 +92,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 diff --git a/tests/kola/ntp/chrony/coreos-platform-chrony-generator b/tests/kola/ntp/chrony/coreos-platform-chrony-generator index 7460509dc1..04ad465a73 100755 --- a/tests/kola/ntp/chrony/coreos-platform-chrony-generator +++ b/tests/kola/ntp/chrony/coreos-platform-chrony-generator @@ -1,7 +1,7 @@ #!/bin/bash ## kola: ## exclusive: false -## platforms: "aws azure gce" +## platforms: "aws azure gce qemu" # # Test the coreos-platform-chrony generator. @@ -14,5 +14,11 @@ 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) + # ptp_kvm isn't available on all arches nor all hosts, so don't assume it's always there; see + # https://github.com/coreos/fedora-coreos-config/pull/2263#discussion_r1157694192 + if lsmod | grep -q ptp_kvm; then + chronyc sources | grep 'PHC0'; echo "ok chrony qemu" + fi ;; *) echo "unhandled platform ${platform} ?"; exit 1 ;; esac