From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38195 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbUSj-0003B5-Gn for qemu-devel@nongnu.org; Sat, 08 Jan 2011 03:47:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PbUSi-00066B-Ai for qemu-devel@nongnu.org; Sat, 08 Jan 2011 03:47:49 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:39980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PbUSh-000664-Rq for qemu-devel@nongnu.org; Sat, 08 Jan 2011 03:47:48 -0500 Message-ID: <4D2824B2.1000807@web.de> Date: Sat, 08 Jan 2011 09:47:46 +0100 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH] Stop current VCPU on synchronous reset requests List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , qemu-devel Cc: Gleb Natapov From: Jan Kiszka If some I/O operation ends up calling qemu_system_reset_request in VCPU context, we record this and inform the io-thread, but we do not terminate the VCPU loop. This can lead to fairly unexpected behavior if the triggering reset operation is supposed to work synchronously. Fix this for TCG (when run in deterministic I/O mode) by setting the VCPU on stop and issuing a cpu_exit. KVM requires some more work on its VCPU loop. [ ported from qemu-kvm ] Signed-off-by: Jan Kiszka --- cpus.c | 13 +++++++++---- cpus.h | 1 + vl.c | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 9bf5224..925a40f 100644 --- a/cpus.c +++ b/cpus.c @@ -99,6 +99,14 @@ void cpu_synchronize_all_post_init(void) } } +void cpu_stop_current(void) +{ + if (cpu_single_env) { + cpu_single_env->stopped = 1; + cpu_exit(cpu_single_env); + } +} + int cpu_is_stopped(CPUState *env) { return !vm_running || env->stopped; @@ -854,10 +862,7 @@ void vm_stop(int reason) * FIXME: should not return to device code in case * vm_stop() has been requested. */ - if (cpu_single_env) { - cpu_exit(cpu_single_env); - cpu_single_env->stop = 1; - } + cpu_stop_current(); return; } do_vm_stop(reason); diff --git a/cpus.h b/cpus.h index fa3f165..e021126 100644 --- a/cpus.h +++ b/cpus.h @@ -6,6 +6,7 @@ int qemu_init_main_loop(void); void qemu_main_loop_start(void); void resume_all_vcpus(void); void pause_all_vcpus(void); +void cpu_stop_current(void); /* vl.c */ extern int smp_cores; diff --git a/vl.c b/vl.c index 193afba..2b9a9da 100644 --- a/vl.c +++ b/vl.c @@ -1278,6 +1278,7 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } + cpu_stop_current(); qemu_notify_event(); } -- 1.7.1