From patchwork Tue Feb 1 21:15:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 81390 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 8C420B70B3 for ; Wed, 2 Feb 2011 09:07:44 +1100 (EST) Received: from localhost ([127.0.0.1]:57622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkOJM-0008DY-JL for incoming@patchwork.ozlabs.org; Tue, 01 Feb 2011 17:02:56 -0500 Received: from [140.186.70.92] (port=46165 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkNhR-0000fT-3q for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:26:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PkNap-0003Gg-M2 for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:16:56 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:33792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PkNao-0003FO-VB for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:16:55 -0500 Received: from smtp05.web.de ( [172.20.4.166]) by fmmailgate02.web.de (Postfix) with ESMTP id ACABE195B18DF; Tue, 1 Feb 2011 22:16:09 +0100 (CET) Received: from [88.65.41.52] (helo=localhost.localdomain) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PkNa5-0006FM-01; Tue, 01 Feb 2011 22:16:09 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Tue, 1 Feb 2011 22:15:43 +0100 Message-Id: <22c2932c3338907497cabeca38816a6973b19c3e.1296594961.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1/nUh27dWhx6T0YrGvHciZExlvGWHCSyJD4Xd2t onXrkKSrvaxrH6Snfojzd5AqRdPo5dryLRYDlX1PQoxZIFYY7f 4tW5qKGaU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH v2 03/24] 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 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 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(); }