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:
@@ -34,8 +34,8 @@ use vmm::vm_config::IvshmemConfig;
|
||||
use vmm::vm_config::{
|
||||
BalloonConfig, ConsoleConfig, DeviceConfig, DiskConfig, FsConfig, GenericVhostUserConfig,
|
||||
LandlockConfig, NetConfig, NumaConfig, PciSegmentConfig, PlatformConfig, PmemConfig,
|
||||
RateLimiterGroupConfig, RngConfig, SerialConfig, TpmConfig, UserDeviceConfig, VdpaConfig,
|
||||
VmConfig, VsockConfig,
|
||||
RateLimiterGroupConfig, RngConfig, RtcConfig, SerialConfig, TpmConfig, UserDeviceConfig,
|
||||
VdpaConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
use vmm_sys_util::signal::block_signal;
|
||||
@@ -404,6 +404,12 @@ fn get_cli_options_sorted(
|
||||
.help(RngConfig::SYNTAX)
|
||||
.default_value(default_rng)
|
||||
.group("vm-config"),
|
||||
Arg::new("rtc")
|
||||
.long("rtc")
|
||||
.help(RtcConfig::SYNTAX)
|
||||
.num_args(0..=1)
|
||||
.default_missing_value("")
|
||||
.group("vm-config"),
|
||||
Arg::new("seccomp")
|
||||
.long("seccomp")
|
||||
.num_args(1)
|
||||
@@ -1043,6 +1049,7 @@ mod unit_tests {
|
||||
iommu: false,
|
||||
numa: None,
|
||||
watchdog: false,
|
||||
rtc: None,
|
||||
#[cfg(feature = "guest_debug")]
|
||||
gdb: false,
|
||||
pci_segments: None,
|
||||
|
||||
Reference in New Issue
Block a user