hypervisor: x86: drop get_msr_list from hypervisor trait

It is not needed by code outside of the hypervisor crate.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-07-18 20:54:17 +00:00 committed by Liu Wei
parent 05e5106b9b
commit 563919fc4a
3 changed files with 25 additions and 25 deletions

View File

@ -12,8 +12,6 @@ use crate::arch::x86::CpuIdEntry;
#[cfg(feature = "tdx")]
use crate::kvm::TdxCapabilities;
use crate::vm::Vm;
#[cfg(target_arch = "x86_64")]
use crate::x86_64::MsrList;
use std::sync::Arc;
use thiserror::Error;
@ -107,11 +105,6 @@ pub trait Hypervisor: Send + Sync {
fn check_required_extensions(&self) -> Result<()> {
Ok(())
}
#[cfg(target_arch = "x86_64")]
///
/// Retrieve the list of MSRs supported by the hypervisor.
///
fn get_msr_list(&self) -> Result<MsrList>;
#[cfg(target_arch = "aarch64")]
///
/// Retrieve AArch64 host maximum IPA size supported by KVM.

View File

@ -875,6 +875,19 @@ fn tdx_command(
pub struct KvmHypervisor {
kvm: Kvm,
}
impl KvmHypervisor {
#[cfg(target_arch = "x86_64")]
///
/// Retrieve the list of MSRs supported by the hypervisor.
///
fn get_msr_list(&self) -> hypervisor::Result<MsrList> {
self.kvm
.get_msr_index_list()
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))
}
}
/// Enum for KVM related error
#[derive(Debug, Error)]
pub enum KvmError {
@ -1003,15 +1016,6 @@ impl hypervisor::Hypervisor for KvmHypervisor {
Ok(v)
}
#[cfg(target_arch = "x86_64")]
///
/// Retrieve the list of MSRs supported by KVM.
///
fn get_msr_list(&self) -> hypervisor::Result<MsrList> {
self.kvm
.get_msr_index_list()
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))
}
#[cfg(target_arch = "aarch64")]
///
/// Retrieve AArch64 host maximum IPA size supported by KVM.

View File

@ -160,6 +160,18 @@ pub struct MshvHypervisor {
mshv: Mshv,
}
impl MshvHypervisor {
#[cfg(target_arch = "x86_64")]
///
/// Retrieve the list of MSRs supported by MSHV.
///
fn get_msr_list(&self) -> hypervisor::Result<MsrList> {
self.mshv
.get_msr_index_list()
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))
}
}
impl MshvHypervisor {
/// Create a hypervisor based on Mshv
pub fn new() -> hypervisor::Result<MshvHypervisor> {
@ -238,15 +250,6 @@ impl hypervisor::Hypervisor for MshvHypervisor {
fn get_cpuid(&self) -> hypervisor::Result<Vec<CpuIdEntry>> {
Ok(Vec::new())
}
#[cfg(target_arch = "x86_64")]
///
/// Retrieve the list of MSRs supported by MSHV.
///
fn get_msr_list(&self) -> hypervisor::Result<MsrList> {
self.mshv
.get_msr_index_list()
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))
}
}
#[allow(dead_code)]