From: Jan Kiszka Date: Fri, 17 Feb 2012 17:31:16 +0000 (+0100) Subject: Allow to use pause_all_vcpus from VCPU context X-Git-Tag: v1.1-rc0~289^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d798e97456658ea7605303b7c69b04ec7df95c10;p=thirdparty%2Fqemu.git 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 Signed-off-by: Jan Kiszka Signed-off-by: Avi Kivity --- diff --git a/cpus.c b/cpus.c index 4a10775cb61..17b055fba00 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;