From 5cd4f5daeb56585e7226979dcdcb66ab17195581 Mon Sep 17 00:00:00 2001 From: Cathy Zhang Date: Tue, 5 Nov 2019 14:03:29 +0800 Subject: [PATCH] vmm: Release the old vm before build a new one In vm_reboot, while build the new vm, the old one pointed by self.vm is not released, that is, the tap opened by self.vm is not closed either. As a result, the associated dev name slot in host kernel is still in use state, which prevents the new build from picking it up as the new opened tap's name, but to use the name in next slot finally. Call self.vm_shutdown instead here since it has call take() on vm reference, which could ensure the old vm is destructed before the new vm build. Signed-off-by: Cathy Zhang --- vmm/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 75f3653cb..dd128fd7c 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -255,16 +255,15 @@ impl Vmm { // Without ACPI, a reset is equivalent to a shutdown #[cfg(not(feature = "acpi"))] { - if let Some(ref mut vm) = self.vm { - vm.shutdown()?; - return Ok(()); + if self.vm.is_some() { + return self.vm_shutdown(); } } // First we stop the current VM and create a new one. if let Some(ref mut vm) = self.vm { let config = vm.get_config(); - vm.shutdown()?; + self.vm_shutdown()?; let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?; let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;