hypervisor: provide a generic ClockData structure

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2022-07-14 14:16:49 +00:00
committed by Liu Wei
parent beb4f86b82
commit 4201bf4011
5 changed files with 68 additions and 15 deletions

View File

@@ -59,7 +59,7 @@ pub use kvm::x86_64;
pub use kvm::{aarch64, GicState};
// Aliased types exposed from both hypervisors
#[cfg(feature = "kvm")]
pub use kvm::{ClockData, CreateDevice, DeviceAttr, DeviceFd, IrqRoutingEntry};
pub use kvm::{CreateDevice, DeviceAttr, DeviceFd, IrqRoutingEntry};
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
pub use mshv::x86_64;
// Aliased types exposed from both hypervisors
@@ -152,3 +152,24 @@ pub enum CpuState {
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
Mshv(mshv::VcpuMshvState),
}
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
#[cfg(target_arch = "x86_64")]
pub enum ClockData {
#[cfg(feature = "kvm")]
Kvm(kvm_bindings::kvm_clock_data),
#[cfg(feature = "mshv")]
Mshv, /* MSHV does not supprt ClockData yet */
}
#[cfg(target_arch = "x86_64")]
impl ClockData {
pub fn reset_flags(&mut self) {
match self {
#[cfg(feature = "kvm")]
ClockData::Kvm(s) => s.flags = 0,
#[allow(unreachable_patterns)]
_ => {}
}
}
}