From 82a0e29c7a06f9f2271bb6d1203f490040cf7b44 Mon Sep 17 00:00:00 2001 From: Michael Zhao Date: Tue, 7 Jul 2020 14:19:15 +0800 Subject: [PATCH] hypervisor: Export check_extension() API from hypervisor::Vm Signed-off-by: Michael Zhao --- hypervisor/src/kvm/mod.rs | 4 ++++ hypervisor/src/vm.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index b99ddc339..87b25a741 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -250,6 +250,10 @@ impl vm::Vm for KvmVm { .set_clock(data) .map_err(|e| vm::HypervisorVmError::SetClock(e.into())) } + /// Checks if a particular `Cap` is available. + fn check_extension(&self, c: Cap) -> bool { + self.fd.check_extension(c) + } } /// Wrapper over KVM system ioctls. pub struct KvmHypervisor { diff --git a/hypervisor/src/vm.rs b/hypervisor/src/vm.rs index 0a5b3fd22..7e2d74e86 100644 --- a/hypervisor/src/vm.rs +++ b/hypervisor/src/vm.rs @@ -14,6 +14,7 @@ use crate::cpu::Vcpu; #[cfg(target_arch = "x86_64")] use crate::ClockData; use crate::{CreateDevice, DeviceFd, IoEventAddress, IrqRouting, MemoryRegion}; +use kvm_ioctls::Cap; use std::sync::Arc; use thiserror::Error; use vmm_sys_util::eventfd::EventFd; @@ -168,4 +169,6 @@ pub trait Vm: Send + Sync { /// Set guest clock. #[cfg(target_arch = "x86_64")] fn set_clock(&self, data: &ClockData) -> Result<()>; + /// Checks if a particular `Cap` is available. + fn check_extension(&self, c: Cap) -> bool; }