From patchwork Thu Jan 27 13:09:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 80689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 86952B6EE8 for ; Fri, 28 Jan 2011 00:31:52 +1100 (EST) Received: from localhost ([127.0.0.1]:45581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiRwy-0007Sy-K8 for incoming@patchwork.ozlabs.org; Thu, 27 Jan 2011 08:31:48 -0500 Received: from [140.186.70.92] (port=49443 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiRcC-0001Vc-Rc for qemu-devel@nongnu.org; Thu, 27 Jan 2011 08:10:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiRc7-0000lr-3b for qemu-devel@nongnu.org; Thu, 27 Jan 2011 08:10:20 -0500 Received: from thoth.sbs.de ([192.35.17.2]:19818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiRc6-0000ik-8J for qemu-devel@nongnu.org; Thu, 27 Jan 2011 08:10:14 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id p0RDAA0T023222; Thu, 27 Jan 2011 14:10:11 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p0RDA72m009974; Thu, 27 Jan 2011 14:10:10 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Thu, 27 Jan 2011 14:09:46 +0100 Message-Id: <5eea0ecd557e7c997f7ab592a5b97747f3b2fdbf.1296133797.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 02/22] Stop current VCPU on synchronous reset requests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 ab6e40e..ceb3a83 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; @@ -863,10 +871,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 bf4d9bb..4cadb64 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 33f844f..db24a05 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(); }