hypervisor: drop kvm guard from some Vcpu trait functions

And provide default implementations.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-07-20 22:02:43 +00:00 committed by Liu Wei
parent cb6a14dec9
commit ae7f74d0a8

View File

@ -21,7 +21,7 @@ use crate::kvm::{TdxExitDetails, TdxExitStatus};
use crate::CpuState; use crate::CpuState;
use crate::MpState; use crate::MpState;
use thiserror::Error; use thiserror::Error;
#[cfg(all(feature = "kvm", target_arch = "x86_64"))] #[cfg(target_arch = "x86_64")]
use vm_memory::GuestAddress; use vm_memory::GuestAddress;
#[derive(Error, Debug)] #[derive(Error, Debug)]
@ -341,17 +341,21 @@ pub trait Vcpu: Send + Sync {
/// Sets the vcpu's current "multiprocessing state". /// Sets the vcpu's current "multiprocessing state".
/// ///
fn set_mp_state(&self, mp_state: MpState) -> Result<()>; fn set_mp_state(&self, mp_state: MpState) -> Result<()>;
#[cfg(all(feature = "kvm", target_arch = "x86_64"))] #[cfg(target_arch = "x86_64")]
/// ///
/// Let the guest know that it has been paused, which prevents from /// Let the guest know that it has been paused, which prevents from
/// potential soft lockups when being resumed. /// potential soft lockups when being resumed.
/// ///
fn notify_guest_clock_paused(&self) -> Result<()>; fn notify_guest_clock_paused(&self) -> Result<()> {
#[cfg(all(feature = "kvm", target_arch = "x86_64"))] Ok(())
}
#[cfg(target_arch = "x86_64")]
/// ///
/// Sets debug registers to set hardware breakpoints and/or enable single step. /// Sets debug registers to set hardware breakpoints and/or enable single step.
/// ///
fn set_guest_debug(&self, addrs: &[GuestAddress], singlestep: bool) -> Result<()>; fn set_guest_debug(&self, _addrs: &[GuestAddress], _singlestep: bool) -> Result<()> {
Err(HypervisorCpuError::SetDebugRegs(anyhow!("unimplemented")))
}
/// ///
/// Sets the type of CPU to be exposed to the guest and optional features. /// Sets the type of CPU to be exposed to the guest and optional features.
/// ///
@ -427,11 +431,10 @@ pub trait Vcpu: Send + Sync {
/// ///
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
fn tdx_init(&self, hob_address: u64) -> Result<()>; fn tdx_init(&self, hob_address: u64) -> Result<()>;
#[cfg(feature = "kvm")]
/// ///
/// Set the "immediate_exit" state /// Set the "immediate_exit" state
/// ///
fn set_immediate_exit(&self, exit: bool); fn set_immediate_exit(&self, _exit: bool) {}
#[cfg(feature = "tdx")] #[cfg(feature = "tdx")]
/// ///
/// Returns the details about TDX exit reason /// Returns the details about TDX exit reason