hypervisor: add a function to return hypervisor type

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2022-07-20 10:41:13 +00:00
committed by Liu Wei
parent d56263706d
commit 9fc3379e8d
4 changed files with 25 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ use crate::arch::x86::CpuIdEntry;
#[cfg(feature = "tdx")]
use crate::kvm::TdxCapabilities;
use crate::vm::Vm;
use crate::HypervisorType;
use std::sync::Arc;
use thiserror::Error;
@@ -82,6 +83,10 @@ pub type Result<T> = std::result::Result<T, HypervisorError>;
/// This crate provides a hypervisor-agnostic interfaces
///
pub trait Hypervisor: Send + Sync {
///
/// Returns the type of the hypervisor
///
fn hypervisor_type(&self) -> HypervisorType;
///
/// Create a Vm using the underlying hypervisor
/// Return a hypervisor-agnostic Vm trait object