Patchwork [v3,3/9] Allow to use pause_all_vcpus from VCPU context

login
register
mail settings
Submitter Jan Kiszka
Date Feb. 14, 2012, 3:13 p.m.
Message ID <2a142f1155027e1fa6e15b0ec58febf70bf7b8a0.1329232393.git.jan.kiszka@siemens.com>
Download mbox | patch
Permalink /patch/141130/
State New
Headers show

Comments

Jan Kiszka - Feb. 14, 2012, 3:13 p.m.
In order to perform critical manipulations on the VM state in the
context of a VCPU, specifically code patching, stopping and resuming of
all VCPUs may be necessary. resume_all_vcpus is already compatible, now
enable pause_all_vcpus for this use case by stopping the calling context
before starting to wait for the whole gang.

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpus.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index 4e65894..290daa8 100644
--- a/cpus.c
+++ b/cpus.c
@@ -870,6 +870,18 @@  void pause_all_vcpus(void)
         penv = penv->next_cpu;
     }
 
+    if (!qemu_thread_is_self(&io_thread)) {
+        cpu_stop_current();
+        if (!kvm_enabled()) {
+            while (penv) {
+                penv->stop = 0;
+                penv->stopped = 1;
+                penv = penv->next_cpu;
+            }
+            return;
+        }
+    }
+
     while (!all_vcpus_paused()) {
         qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
         penv = first_cpu;