mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Implement virtio-device rtc
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_MAYBE_SMEARED with leap_second_smearing VIRTIO_RTC_SMEAR_UNSPECIFIED The device is disabled by default, requiring --rtc to be passed Not implemented but theoretically supported by virtio-rtc is: 1. Cross-timestamping support 2. The alarm queue Fixes #7730 Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
This commit is contained in:
@@ -33,6 +33,7 @@ pub enum VirtioDeviceType {
|
||||
Balloon = 5,
|
||||
Fs9P = 9,
|
||||
Gpu = 16,
|
||||
Rtc = 17,
|
||||
Input = 18,
|
||||
Vsock = 19,
|
||||
Iommu = 23,
|
||||
@@ -53,6 +54,7 @@ impl From<u32> for VirtioDeviceType {
|
||||
5 => VirtioDeviceType::Balloon,
|
||||
9 => VirtioDeviceType::Fs9P,
|
||||
16 => VirtioDeviceType::Gpu,
|
||||
17 => VirtioDeviceType::Rtc,
|
||||
18 => VirtioDeviceType::Input,
|
||||
19 => VirtioDeviceType::Vsock,
|
||||
23 => VirtioDeviceType::Iommu,
|
||||
@@ -76,8 +78,9 @@ impl fmt::Display for VirtioDeviceType {
|
||||
VirtioDeviceType::Console => "console",
|
||||
VirtioDeviceType::Rng => "rng",
|
||||
VirtioDeviceType::Balloon => "balloon",
|
||||
VirtioDeviceType::Gpu => "gpu",
|
||||
VirtioDeviceType::Fs9P => "9p",
|
||||
VirtioDeviceType::Gpu => "gpu",
|
||||
VirtioDeviceType::Rtc => "rtc",
|
||||
VirtioDeviceType::Input => "input",
|
||||
VirtioDeviceType::Vsock => "vsock",
|
||||
VirtioDeviceType::Iommu => "iommu",
|
||||
|
||||
Reference in New Issue
Block a user