From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqeO0-00076c-2d for qemu-devel@nongnu.org; Thu, 14 Apr 2016 06:20:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqeNx-0006yt-2Y for qemu-devel@nongnu.org; Thu, 14 Apr 2016 06:20:31 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:16142 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqeNw-0006x8-DU for qemu-devel@nongnu.org; Thu, 14 Apr 2016 06:20:28 -0400 From: "Denis V. Lunev" Date: Thu, 14 Apr 2016 13:20:15 +0300 Message-Id: <1460629215-11567-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH for 2.6 1/1] nbd: fix assert() on qemu-nbd stop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: den@openvz.org, Pavel Butsykin , Paolo Bonzini From: Pavel Butsykin >>From time to time qemu-nbd is crashing on the following assert: assert(state == TERMINATING); nbd_export_closed nbd_export_put main and the state at the moment of the crash is evaluated to TERMINATE. During shutdown process of the client the nbd_client_thread thread sends SIGTERM signal and the main thread calls the nbd_client_closed callback. If the SIGTERM callback will be executed after change the state to TERMINATING, then the state will once again be TERMINATE. To solve the issue, we must change the state to TERMINATE only if the state is RUNNING. In the other case we are shutting down already. Signed-off-by: Pavel Butsykin Signed-off-by: Denis V. Lunev CC: Paolo Bonzini --- qemu-nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index ca4a724..956013f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -213,7 +213,7 @@ static int find_partition(BlockBackend *blk, int partition, static void termsig_handler(int signum) { - state = TERMINATE; + atomic_cmpxchg(&state, RUNNING, TERMINATE); qemu_notify_event(); } -- 2.1.4