From 18e7d7a1f785605982cb867bf7762d195e8287a6 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 24 Jun 2020 12:25:06 +0200 Subject: [PATCH] vmm: cpu: Resume before shutdown in a specific way Instead of calling the resume() function from the CpuManager, which involves more than what is needed from the shutdown codepath, and potentially ends up with a deadlock, we replace it with a subset. The full resume operation is reserved for a VM that has been paused. Signed-off-by: Sebastien Boeuf --- vmm/src/cpu.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 9ec481458..b7453c633 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -944,8 +944,13 @@ impl CpuManager { // Tell the vCPUs to stop themselves next time they go through the loop self.vcpus_kill_signalled.store(true, Ordering::SeqCst); - // Clear pause state and unpark the vCPU threads if they are parked. - self.resume().map_err(Error::ResumeOnShutdown)?; + // Toggle the vCPUs pause boolean + self.vcpus_pause_signalled.store(false, Ordering::SeqCst); + + // Unpark all the VCPU threads. + for state in self.vcpu_states.iter() { + state.unpark_thread(); + } // Signal to the spawned threads (vCPUs and console signal handler). For the vCPU threads // this will interrupt the KVM_RUN ioctl() allowing the loop to check the boolean set