virtio-devices: Implement a backend for virtio-rtc#7795
virtio-devices: Implement a backend for virtio-rtc#7795Camelron wants to merge 3 commits intocloud-hypervisor:mainfrom
Conversation
20490ff to
8071262
Compare
|
Since it is probably relevant, I tested the case where we have a kvm-based guest with a kernel with both VIRTIO_PTP and CONFIG_PTP_1588_CLOCK_KVM. Here we see that they are both available. The consequence of this is that guest images may need udev rules to distinguish between them e.g. |
|
Does MSHV already have a paravirtualized timekeeping device? |
8071262 to
d9e65fd
Compare
We do--hyperv_clocksource_tsc_page. However hyperv_clocksource_tsc_page is a host-controlled clock, not a guest PHC device which is steerable in the guest by something like chronyd. |
|
Your PR and commit messages are missing a |
d6f64e8 to
76738c2
Compare
2ed954a to
12f98a9
Compare
12f98a9 to
ac105ed
Compare
|
ping @Camelron please fix your commit message and the CI |
e63a78b to
ee0be56
Compare
|
Looking at the Tests (arm64) failure, it appears to be failing to build the devices crate due to a missing cached dependency? Hopefully transient? Looking at the x86 failures, I see now that the tests depend on the ordering of PCI devices added to the guest. Pushing a fix to make virtio_rtc the last PCI device added (bdf 09..) since it was added most recently. Also incrementing the expected /sys/bus/pci/devices count to 9. The virtio_rtc test appears to be failing despite recently merging the change to enable the virtio-rtc driver in the guest kernel: cloud-hypervisor/linux#26 . @weltling @phip1611 is there a way to verify in the CI what kernel version we use for the guest? I see that we are using 6.16.9+ which is the branch I merged the config change into.. |
As far as it shows, there's no new kernel release yet, so guess it's not updated on CI yet. For the other tests - those seem irrelevant. Though, you could just retrigger the PR or check as a PR against your own fork, if it tells the diff. But most likely not necessary. Thanks |
5ccd181 to
cdb3bc2
Compare
|
I see all tests passing except the new virtio_rtc one https://productionresultssa9.blob.core.windows.net/actions-results/523784af-3a03-45ad-9c14-2ed707123c35/workflow-job-run-6c0528a0-29fa-5100-b69e-2e46da316d43/logs/job/job-logs.txt?rsct=text%2Fplain&se=2026-03-31T20%3A17%3A46Z&sig=wZ7EGKxhVgJAdQ5g6v3s9PDmF%2FSnj%2BfwA451bTFKAbc%3D&ske=2026-03-31T22%3A36%3A50Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2026-03-31T18%3A36%3A50Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-11-05&sp=r&spr=https&sr=b&st=2026-03-31T20%3A07%3A41Z&sv=2025-11-05. We are now waiting for a release 03/24 or later here https://github.com/cloud-hypervisor/linux/releases to verify that the new test passes once the driver is available in the guest. Thanks! |
Is someone actively working on that? What are the next steps to proceed here? Sorry, I don't have the full context of this right now |
|
There is a pending release for the kernel by github-actions. @rbradford @likebreath can we publish that? |
Done! Here it is: https://github.com/cloud-hypervisor/linux/releases/tag/ch-release-v6.16.9-20260324 |
a7583a6 to
2853baa
Compare
2853baa to
f24f8c0
Compare
83f2c6d to
244e9d8
Compare
|
@rbradford all changes in the CI are now accounted for and we are passing. Mind taking a final look? Thank you. |
rbradford
left a comment
There was a problem hiding this comment.
I don't think this should always be included as PCI slots are valuable resource on segment 0, especially on KVM where there is already kvmclock and this doesn't add any functionality.
Please make it conditional like watchdog - I would be happy for it to be a different default depending on the running hypervisor.
| assert!( | ||
| exec_host_command_status(&format!( | ||
| "sudo ip link add link {phy_net} name {host_macvtap_name} type macvtap mod bridge" | ||
| "sudo ip link add link {phy_net} name {host_macvtap_name} type macvtap mode bridge" |
There was a problem hiding this comment.
I'm assuming this worked before but it just nicer aesthetically? It's a good change but it deserves its own commit.
There was a problem hiding this comment.
I did hit a failure due to this "mod bridge" hence the change. I don't see how though with the CI already persisting long before I came around. Will pull it out for now and see if things pass as-is.
| VirtioDeviceType::Vsock => "vsock", | ||
| VirtioDeviceType::Iommu => "iommu", | ||
| VirtioDeviceType::Mem => "mem", | ||
| VirtioDeviceType::Rtc => "rtc", |
There was a problem hiding this comment.
I feel like this should be in the same order as the numerical order (i.e. same order as From<..> implementation,
Yup, please no more implicit default devices. This makes BDF handling in management software (e.g., libvirt) more complicated. |
|
@Camelron Ping? |
|
Sorry, I've been heads down on some other tasks. Will address requested changes today. |
f711a6f to
6b4ad2d
Compare
| VirtioDeviceType::Rng => "rng", | ||
| VirtioDeviceType::Balloon => "balloon", | ||
| VirtioDeviceType::Gpu => "gpu", | ||
| VirtioDeviceType::Fs9P => "9p", |
There was a problem hiding this comment.
9p was in the wrong order too so I moved it. Can be separated out if preferred.
Move to the latest release for cloud-hypervisor/linux. Contains configs needed for virtio-rtc Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
6b4ad2d to
9cb7ded
Compare
This change will allow us to get accurate time over ptp in guests started from a MSHV-virtualized Linux host. Implementing it as a virtio device is preferable to using the existing kvm_ptp because: kvm_ptp relies on hypercalls that only exist on host kernels running kvm. Virtio-rtc gives us more flexibility in what clock types we want to provide. We can later extend the device to implement multiple clocks (smeared UTC, TAI, monotonic, etc.). Virtio-rtc protocol supports alarms. Alarms may later enable usecases where the guests can do their own VM lifecycle management without relying on a host-side orchestrator. Implement device backend for virtio-rtc. Currently this implementation encompasses: 1. CONFIG, CAP, READ, CROSSCAP (returns false) 2. One PTP clock is presented of type VIRTIO_RTC_CLOCK_UTC_SMEARED The device is disable by default, requiring --virtio-rtc to be passed Not implemented but theoretically supported by virtio-rtc is: 1. Cross-timestamping support 2. The alarm queue Fixes cloud-hypervisor#7730 Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
Integration test for virtio-devices/src/rtc.rs. Requires that the test kernel has the following configs: CONFIG_PTP_1588_CLOCK=y CONFIG_VIRTIO_RTC=y CONFIG_VIRTIO_RTC_PTP=y Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
9cb7ded to
b7f20c1
Compare
|
@rbradford all comments should now be addressed. |
Motivation
This change will allow us to get accurate time over ptp in guests started from
a MSHV-virtualized Linux host. Implementing it as a virtio device is preferable
to using the existing kvm_ptp because:
kvm_ptp relies on hypercalls that only exist on host kernels running kvm.
virtio-rtc gives us more flexibility in what clock types we want to provide.
We can later extend the device to implement multiple clocks
(smeared UTC, TAI, monotonic, etc.). Virtio-rtc protocol supports alarms.
Alarms may later enable usecases where the guests can do their own VM lifecycle
management without relying on a host-side orchestrator.
Change
Implement device backend for virtio-rtc. Currently this implementation
encompasses:
KVM guests can already use kvm_ptp which is synchronous
and therefore, more accurate.
Not implemented but theoretically supported by virtio-rtc is:
Fixes #7730