diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 4fc04a6ab..159686e90 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -905,7 +905,8 @@ pub enum KvmError { pub type KvmResult = result::Result; impl KvmHypervisor { /// Create a hypervisor based on Kvm - pub fn new() -> hypervisor::Result { + #[allow(clippy::new_ret_no_self)] + pub fn new() -> hypervisor::Result> { let kvm_obj = Kvm::new().map_err(|e| hypervisor::HypervisorError::VmCreate(e.into()))?; let api_version = kvm_obj.get_api_version(); @@ -913,7 +914,7 @@ impl KvmHypervisor { return Err(hypervisor::HypervisorError::IncompatibleApiVersion); } - Ok(KvmHypervisor { kvm: kvm_obj }) + Ok(Arc::new(KvmHypervisor { kvm: kvm_obj })) } } /// Implementation of Hypervisor trait for KVM diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index 6b798d462..118b8d414 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -74,7 +74,7 @@ pub fn new() -> std::result::Result, HypervisorError> { #[cfg(feature = "mshv")] let hv = mshv::MshvHypervisor::new()?; - Ok(Arc::new(hv)) + Ok(hv) } // Returns a `Vec` with a size in bytes at least as large as `size_in_bytes`. diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index f99c5c50e..d7d6972ab 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -177,10 +177,11 @@ impl MshvHypervisor { impl MshvHypervisor { /// Create a hypervisor based on Mshv - pub fn new() -> hypervisor::Result { + #[allow(clippy::new_ret_no_self)] + pub fn new() -> hypervisor::Result> { let mshv_obj = Mshv::new().map_err(|e| hypervisor::HypervisorError::HypervisorCreate(e.into()))?; - Ok(MshvHypervisor { mshv: mshv_obj }) + Ok(Arc::new(MshvHypervisor { mshv: mshv_obj })) } } /// Implementation of Hypervisor trait for Mshv