7

I'm trying to run software which needs to get hardware timestamps using ptp. Therefore, I need to have /dev/ptp0 available. I'm running Linux/Ubuntu on a VMWare.

Is there a way to make this work on a VM?

Thanks!

3 Answers 3

9

in short: ptp_kvm.ko

# modprobe ptp_kvm
# ls /dev/ptp*
/dev/ptp0  /dev/ptp_kvm

in long:

Red Hat Enterprise Linux 7.5 and later provide a virtual PTP hardware clock (PHC), which enables the guests to synchronize to the host with a sub-microsecond accuracy.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/chap-kvm_guest_timing_management#sect-KVM_guest_timing_management-Host-guest-time-sync (subscription-wall?)

To enable the PHC device, do the following inside a virtual machine:

Set the ptp_kvm module to load after reboot.

# echo ptp_kvm > /etc/modules-load.d/ptp_kvm.conf

Add the /dev/ptp0 clock as a reference to the chrony configuration:

# echo "refclock PHC /dev/ptp0 poll 2" >> /etc/chrony.conf

Restart the chrony daemon:

# systemctl restart chronyd

To verify the host-guest time synchronization has been configured correctly, use the chronyc sources command on a guest.

# chronyc sources
#* PHC0                          0   2   377     4     -6ns[   -6ns] +/-  726ns
4

Simple answer VMware doesn't support linuxptp emulating ptp devices. Closest thing is find this on this website

FYI Running linuxptp on qemu-kvm

Run two virtual machines for GM and Slave and use recent Fedora, RHEL 6.5 7.0 Use virtual NIC emulationg e10000 (supports software timestamping) don't forget to define appropriate firewall rules to allow multi-cast dont' expect high precision and accuracy

3
  • Thank you for your answer. Is there no way to emulate the ptp hardware clock? I need it only for testing my application. Or is there any other way to get hardware timestamps? Jul 9, 2018 at 12:07
  • never tried this but you can give this a try. it git repo simulating clock. may help. let me know i it worked.
    – Devidas
    Jul 9, 2018 at 13:00
  • So thank you! I'm still trying to understand what it does...is it simulating a ptp hardware clock? Because this is what I would need... Jul 9, 2018 at 14:55
2

It's now 2021, and I found out that if you're able to compile your own Linux Kernel, there is a built-in driver already. Enable it with make menuconfig:

Device Drivers --> PTP clock support --> KVM virtual PTP clock

Inside a KVM guest, a new /dev/ptp0 device will appear, as well as the following Kernel boot log:

pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
PTP clock support registered

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.