From 0cf9218d3ff7f032219876ca4bb3035abb027846 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 19 May 2021 13:09:13 +0000 Subject: [PATCH] hypervisor, vmm: Add default Hypervisor::check_required_extensions() This allows the removal of KVM specific compile time checks on this function. Signed-off-by: Rob Bradford --- hypervisor/src/hypervisor.rs | 5 +++-- vmm/src/vm.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hypervisor/src/hypervisor.rs b/hypervisor/src/hypervisor.rs index 57ae3a2b0..aea750e48 100644 --- a/hypervisor/src/hypervisor.rs +++ b/hypervisor/src/hypervisor.rs @@ -83,11 +83,12 @@ pub trait Hypervisor: Send + Sync { /// Get the supported CpuID /// fn get_cpuid(&self) -> Result; - #[cfg(not(feature = "mshv"))] /// /// Check particular extensions if any /// - fn check_required_extensions(&self) -> Result<()>; + fn check_required_extensions(&self) -> Result<()> { + Ok(()) + } #[cfg(target_arch = "x86_64")] /// /// Retrieve the list of MSRs supported by the hypervisor. diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index f0b6a5802..990a40f01 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -674,7 +674,7 @@ impl Vm { ) -> Result { #[cfg(feature = "tdx")] let tdx_enabled = config.lock().unwrap().tdx.is_some(); - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] hypervisor.check_required_extensions().unwrap(); #[cfg(feature = "tdx")] let vm = hypervisor @@ -746,7 +746,7 @@ impl Vm { hypervisor: Arc, activate_evt: EventFd, ) -> Result { - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] hypervisor.check_required_extensions().unwrap(); let vm = hypervisor.create_vm().unwrap(); #[cfg(target_arch = "x86_64")] @@ -799,7 +799,7 @@ impl Vm { hypervisor: Arc, activate_evt: EventFd, ) -> Result { - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] + #[cfg(target_arch = "x86_64")] hypervisor.check_required_extensions().unwrap(); let vm = hypervisor.create_vm().unwrap(); #[cfg(target_arch = "x86_64")]