aboutsummaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2012-02-17 18:31:16 +0100
committerAvi Kivity <avi@redhat.com>2012-02-18 12:15:54 +0200
commitd798e97456658ea7605303b7c69b04ec7df95c10 (patch)
tree2ebd3824494e504fb5a058a62fd9339b1396cdef /cpus.c
parent8e564b4ebf472095b7ca5692302c8a3883d99d91 (diff)
downloadqemu-d798e97456658ea7605303b7c69b04ec7df95c10.zip
qemu-d798e97456658ea7605303b7c69b04ec7df95c10.tar.gz
qemu-d798e97456658ea7605303b7c69b04ec7df95c10.tar.bz2
Allow to use pause_all_vcpus from VCPU context
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> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/cpus.c b/cpus.c
index 4a10775..17b055f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -875,6 +875,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;