hypervisor: introduce a new function
It returns an hypervisor object depending on which hypervisor is
configured.  Currently it only supports KVM.
@@ -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<Arc<dyn Hypervisor>, HypervisorError> {
+ #[cfg(feature = "kvm")]
+ let hv = kvm::KvmHypervisor::new()?;
+
+ Ok(Arc::new(hv))
+}
