From 801e72ac6da4a35d12b1dc95a893d7d24e124ef9 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 6 May 2020 10:24:19 +0100 Subject: [PATCH] vmm: cpu: Unpause vCPU threads After setting the kill signal flag for the vCPU thread release the pause flag and unpark the threads. This ensures that that the vCPU thread will wake up and check the kill signal flag if the VM is paused. Signed-off-by: Rob Bradford --- vmm/src/cpu.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 38dab7091..8c8c7a0b4 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -193,6 +193,9 @@ pub enum Error { /// Failed to set KVM vcpu XCRS. VcpuSetXcrs(kvm_ioctls::Error), + + /// Error resuming vCPU on shutdown + ResumeOnShutdown(MigratableError), } pub type Result = result::Result; @@ -953,6 +956,9 @@ 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)?; + // 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 // above.