From patchwork Fri Feb 4 15:47:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 81911 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 665BFB7139 for ; Sat, 5 Feb 2011 03:05:24 +1100 (EST) Received: from localhost ([127.0.0.1]:51190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlO9x-0005GA-9L for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 11:05:21 -0500 Received: from [140.186.70.92] (port=51649 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlNut-000617-UB for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlNus-0007yB-Gw for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlNus-0007xI-7X for qemu-devel@nongnu.org; Fri, 04 Feb 2011 10:49:46 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p14FnjOC031909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Feb 2011 10:49:45 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p14FnjKg016899; Fri, 4 Feb 2011 10:49:45 -0500 Received: from amt.cnet (vpn2-8-97.ams2.redhat.com [10.36.8.97]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p14Fnh2O002225; Fri, 4 Feb 2011 10:49:44 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 662B9652028; Fri, 4 Feb 2011 13:47:42 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p14FlcE7017668; Fri, 4 Feb 2011 13:47:38 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Fri, 4 Feb 2011 13:47:05 -0200 Message-Id: <161309b81dc0e3b890fb44cd5f4417c9f39ce43a.1296834446.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 02/23] 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 Signed-off-by: Marcelo Tosatti --- 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 655617f..b1dc3ff 100644 --- a/vl.c +++ b/vl.c @@ -1296,6 +1296,7 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } + cpu_stop_current(); qemu_notify_event(); }