From a3dfe726f8e62213daea8632bb20de3c36ab298b Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 18 Feb 2022 09:06:19 +0100 Subject: [PATCH] vmm: cpu: Avoid useless cloning of Arc> Since the object returned from CpuManager.create_vcpu() is never used, we can avoid the cloning of this object. Signed-off-by: Sebastien Boeuf --- vmm/src/cpu.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index d9eb3d2ee..320d669bb 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -648,7 +648,7 @@ impl CpuManager { cpu_id: u8, entry_point: Option, snapshot: Option, - ) -> Result>> { + ) -> Result<()> { info!("Creating vCPU: cpu_id = {}", cpu_id); let mut vcpu = Vcpu::new(cpu_id, &self.vm, Some(self.vmmops.clone()))?; @@ -676,9 +676,9 @@ impl CpuManager { // Adding vCPU to the CpuManager's vCPU list. let vcpu = Arc::new(Mutex::new(vcpu)); - self.vcpus.push(Arc::clone(&vcpu)); + self.vcpus.push(vcpu); - Ok(vcpu) + Ok(()) } /// Only create new vCPUs if there aren't any inactive ones to reuse