From a83bd97e0dd3a61281e97fbf406e1abe70b3eae1 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Tue, 14 Jul 2020 11:34:42 +0000 Subject: [PATCH] hypervisor: introduce a new function It returns an hypervisor object depending on which hypervisor is configured. Currently it only supports KVM. Signed-off-by: Wei Liu --- hypervisor/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index 66402f412..45c48f864 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -44,3 +44,11 @@ pub use crate::hypervisor::{Hypervisor, HypervisorError}; pub use cpu::{HypervisorCpuError, Vcpu, VmExit}; pub use kvm::*; pub use vm::{DataMatch, HypervisorVmError, Vm}; + +use std::sync::Arc; +pub fn new() -> std::result::Result, HypervisorError> { + #[cfg(feature = "kvm")] + let hv = kvm::KvmHypervisor::new()?; + + Ok(Arc::new(hv)) +}