From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XigJN-0000rM-Tv for qemu-devel@nongnu.org; Mon, 27 Oct 2014 05:10:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XigJJ-0001Mt-6q for qemu-devel@nongnu.org; Mon, 27 Oct 2014 05:10:01 -0400 Sender: Paolo Bonzini Message-ID: <544E0BD4.9010803@redhat.com> Date: Mon, 27 Oct 2014 10:09:40 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <544CBFA1.1090108@web.de> In-Reply-To: <544CBFA1.1090108@web.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka , Peter Maydell , qemu-devel Cc: =?UTF-8?B?QWxleCBCZW5uw6ll?= , qemu-stable , Stefan Hajnoczi , Gonglei On 10/26/2014 10:32 AM, Jan Kiszka wrote: > 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. > > Signed-off-by: Jan Kiszka --- vl.c | 4 > +--- 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/vl.c b/vl.c index 2f81384..f6b3546 100644 --- a/vl.c > +++ b/vl.c @@ -1609,9 +1609,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) > Cc: qemu-stable@nongnu.org Reviewed-by: Paolo Bonzini Are you going to send a pull request yourself?