[PATCH v2 4/4] accel/mshv: break the vCPU run loop on exit_request

Doru Blânzeanu <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <[email protected]>
Ignored VM exits can cause mshv_cpu_exec() to re-enter MSHV_RUN_VP
without returning to qemu_process_cpu_events(). A busy vCPU may
prevent pause_all_vcpus() from completing.

Check exit_request before re-entering MSHV_RUN_VP and return
EXCP_INTERRUPT so pending stop requests can be processed.

Signed-off-by: Doru Blânzeanu <[email protected]>
---
 accel/mshv/mshv-all.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c
index afcb87b3b8..b7c1126fe0 100644
--- a/accel/mshv/mshv-all.c
+++ b/accel/mshv/mshv-all.c
@@ -780,6 +780,16 @@ static int mshv_cpu_exec(CPUState *cpu)
             cpu->vcpu_dirty = false;
         }
 
+        /*
+         * A kick/stop can't reliably break MSHV_RUN_VP out, so leave the run
+         * loop here too; otherwise a busy vCPU never reaches
+         * qemu_process_cpu_events() and pause_all_vcpus() hangs under the BQL.
+         */
+        if (cpu->stop || qatomic_load_acquire(&cpu->exit_request)) {
+            ret = EXCP_INTERRUPT;
+            break;
+        }
+
         ret = mshv_run_vcpu(mshv_state->vm, cpu, &mshv_msg, &exit_reason);
         if (ret < 0) {
             error_report("Failed to run on vcpu %d", cpu->cpu_index);
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.