diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index 38ecb7cf1..ce24e7b6f 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -30,7 +30,7 @@ use crate::arch::aarch64::ExtendedReg; use crate::arch::x86::{CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters}; #[cfg(feature = "tdx")] use crate::kvm::{TdxExitDetails, TdxExitStatus}; -use crate::{CpuState, MpState, StandardRegisters}; +use crate::{CpuState, HypervisorType, MpState, StandardRegisters}; #[cfg(target_arch = "x86_64")] #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize)] @@ -679,4 +679,9 @@ pub trait Vcpu: Send + Sync { /// Trigger NMI interrupt /// fn nmi(&self) -> Result<()>; + + /// + /// The type of the hypervisor backing this vCPU + /// + fn hypervisor_type(&self) -> HypervisorType; } diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 70b4423c2..4c84feb88 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -3765,6 +3765,10 @@ impl cpu::Vcpu for KvmVcpu { Ok(()) } + + fn hypervisor_type(&self) -> HypervisorType { + HypervisorType::Kvm + } } #[cfg(target_arch = "aarch64")] diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index c861af14f..a56a290d8 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1626,6 +1626,10 @@ impl cpu::Vcpu for MshvVcpu { Ok(()) } + + fn hypervisor_type(&self) -> HypervisorType { + HypervisorType::Mshv + } } impl MshvVcpu {