From patchwork Thu Jan 8 17:33:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 426765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2BCE61400B7 for ; Fri, 9 Jan 2015 04:59:11 +1100 (AEDT) Received: from localhost ([::1]:47296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9HMT-0005I1-AV for incoming@patchwork.ozlabs.org; Thu, 08 Jan 2015 12:59:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Gzz-0004AU-89 for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9Gzl-0006jM-4e for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:35:55 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:53173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Gzk-0006if-CD for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:35:41 -0500 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Jan 2015 10:35:39 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Jan 2015 10:35:35 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id D07261FF001B; Thu, 8 Jan 2015 10:24:18 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t08HZYnt53411964; Thu, 8 Jan 2015 10:35:34 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t08HZY6F027595; Thu, 8 Jan 2015 10:35:34 -0700 Received: from localhost (morrigu.austin.ibm.com [9.41.105.45]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t08HZYvX027561; Thu, 8 Jan 2015 10:35:34 -0700 From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 8 Jan 2015 11:33:53 -0600 Message-Id: <1420738472-23267-50-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15010817-0029-0000-0000-0000070BC59C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.159 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 49/88] Make qemu_shutdown_requested signal-safe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka qemu_shutdown_requested may be interrupted by qemu_system_killed. If the latter sets shutdown_requested after qemu_shutdown_requested has read it but before it was cleared, the shutdown event is lost. Fix this by using atomic_xchg. This provides a different fix for the problem which commit 15124e142 attempts to deal with. That commit breaks use of ^C to drop into gdb, and so this approach is better (and 15124e142 can be reverted). Signed-off-by: Jan Kiszka Reviewed-by: Gonglei Reviewed-by: Paolo Bonzini [PMM: commit message tweak] Signed-off-by: Peter Maydell (cherry picked from commit 817ef04db2cfa2df04daffd6917f4ea7605f6403) Signed-off-by: Michael Roth --- vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 7f8bd39..3650f4f 100644 --- a/vl.c +++ b/vl.c @@ -1745,9 +1745,7 @@ int qemu_reset_requested_get(void) static int qemu_shutdown_requested(void) { - int r = shutdown_requested; - shutdown_requested = 0; - return r; + return atomic_xchg(&shutdown_requested, 0); } static void qemu_kill_report(void)