From 24396257852d1f7d643a7755cd246569dea74eae Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 19 May 2021 13:01:11 +0000 Subject: [PATCH] hypervisor: Cleanup unused Hypervisor trait members Signed-off-by: Rob Bradford --- hypervisor/src/hypervisor.rs | 32 -------------------------------- hypervisor/src/kvm/mod.rs | 27 --------------------------- vmm/src/cpu.rs | 2 +- 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/hypervisor/src/hypervisor.rs b/hypervisor/src/hypervisor.rs index 7f1cc8a21..57ae3a2b0 100644 --- a/hypervisor/src/hypervisor.rs +++ b/hypervisor/src/hypervisor.rs @@ -12,8 +12,6 @@ use crate::vm::Vm; use crate::x86_64::CpuId; #[cfg(target_arch = "x86_64")] use crate::x86_64::MsrList; -#[cfg(all(feature = "kvm", target_arch = "x86_64"))] -use kvm_ioctls::Cap; use std::sync::Arc; use thiserror::Error; @@ -42,16 +40,6 @@ pub enum HypervisorError { #[error("Failed to get API Version: {0}")] GetApiVersion(#[source] anyhow::Error), /// - /// Vcpu mmap error - /// - #[error("Failed to get Vcpu Mmap: {0}")] - GetVcpuMmap(#[source] anyhow::Error), - /// - /// Max Vcpu error - /// - #[error("Failed to get number of max vcpus: {0}")] - GetMaxVcpu(#[source] anyhow::Error), - /// /// CpuId error /// #[error("Failed to get cpuid: {0}")] @@ -90,26 +78,6 @@ pub trait Hypervisor: Send + Sync { /// Return a hypervisor-agnostic Vm trait object /// fn create_vm_with_type(&self, vm_type: u64) -> Result>; - #[cfg(feature = "kvm")] - /// - /// Returns the size of the memory mapping required to use the vcpu's structures - /// - fn get_vcpu_mmap_size(&self) -> Result; - #[cfg(feature = "kvm")] - /// - /// Gets the recommended maximum number of VCPUs per VM. - /// - fn get_max_vcpus(&self) -> Result; - #[cfg(feature = "kvm")] - /// - /// Gets the recommended number of VCPUs per VM. - /// - fn get_nr_vcpus(&self) -> Result; - #[cfg(all(feature = "kvm", target_arch = "x86_64"))] - /// - /// Checks if a particular `Cap` is available. - /// - fn check_capability(&self, c: Cap) -> bool; #[cfg(target_arch = "x86_64")] /// /// Get the supported CpuID diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 18b894fed..01c243db3 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -565,33 +565,6 @@ impl hypervisor::Hypervisor for KvmHypervisor { Ok(()) } - /// - /// Returns the size of the memory mapping required to use the vcpu's `kvm_run` structure. - /// - fn get_vcpu_mmap_size(&self) -> hypervisor::Result { - self.kvm - .get_vcpu_mmap_size() - .map_err(|e| hypervisor::HypervisorError::GetVcpuMmap(e.into())) - } - /// - /// Gets the recommended maximum number of VCPUs per VM. - /// - fn get_max_vcpus(&self) -> hypervisor::Result { - Ok(self.kvm.get_max_vcpus()) - } - /// - /// Gets the recommended number of VCPUs per VM. - /// - fn get_nr_vcpus(&self) -> hypervisor::Result { - Ok(self.kvm.get_nr_vcpus()) - } - #[cfg(target_arch = "x86_64")] - /// - /// Checks if a particular `Cap` is available. - /// - fn check_capability(&self, c: Cap) -> bool { - self.kvm.check_extension(c) - } #[cfg(target_arch = "x86_64")] /// /// X86 specific call to get the system supported CPUID values. diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index fa6eac059..fca23affd 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -1502,7 +1502,7 @@ mod tests { fn test_setlint() { let hv = hypervisor::new().unwrap(); let vm = hv.create_vm().expect("new VM fd creation failed"); - assert!(hv.check_capability(hypervisor::kvm::Cap::Irqchip)); + assert!(hv.check_required_extensions().is_ok()); // Calling get_lapic will fail if there is no irqchip before hand. assert!(vm.create_irq_chip().is_ok()); let vcpu = vm.create_vcpu(0, None).unwrap();