From patchwork Wed Mar 15 17:46:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon X-Patchwork-Id: 9626293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 596276048C for ; Wed, 15 Mar 2017 17:46:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F11228660 for ; Wed, 15 Mar 2017 17:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43B3F28666; Wed, 15 Mar 2017 17:46:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64F7B28665 for ; Wed, 15 Mar 2017 17:46:35 +0000 (UTC) Received: from localhost ([::1]:38797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coD0L-0007d4-Pl for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 Mar 2017 13:46:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coD09-0007cv-JQ for qemu-devel@nongnu.org; Wed, 15 Mar 2017 13:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coD04-0000Hu-Ek for qemu-devel@nongnu.org; Wed, 15 Mar 2017 13:46:21 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:60509) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coD04-0000Em-7i for qemu-devel@nongnu.org; Wed, 15 Mar 2017 13:46:16 -0400 Received: from mfilter5-d.gandi.net (mfilter5-d.gandi.net [217.70.178.132]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 8AE141720D3; Wed, 15 Mar 2017 18:46:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter5-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter5-d.gandi.net (mfilter5-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id DghluIatMFc9; Wed, 15 Mar 2017 18:46:13 +0100 (CET) X-Originating-IP: 10.58.1.145 Received: from webmail.eu.com (webmail5-d.mgt.gandi.net [10.58.1.145]) (Authenticated sender: lists@whitewinterwolf.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPA id 1CDD01720BE; Wed, 15 Mar 2017 18:46:11 +0100 (CET) MIME-Version: 1.0 Date: Wed, 15 Mar 2017 18:46:11 +0100 From: Simon To: "Daniel P. Berrange" In-Reply-To: <20170315144124.GP7770@redhat.com> References: <11569d75b61122820f186a32cdd20689@whitewinterwolf.com> <20170315144124.GP7770@redhat.com> Message-ID: <23d89ab3bd16ebf7a864ab75c300de7b@whitewinterwolf.com> X-Sender: qemu.bugs@whitewinterwolf.com User-Agent: Roundcube Webmail/1.1.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.70.183.196 Subject: Re: [Qemu-devel] [Bug 1217339] [PATCH] Unix signal to send ACPI-shutdown to Guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Daniel P. Berrange: > > While I understand your motivation this creates a semantic change for > existing users of QEMU. IOW anyone who is currently relying on use > of SIGHUP will experiance a regression when upgrading QEMU. > > So if we want to signal to generate a clean shutdown, we need to pick > one that QEMU hasn't already set a specific behaviour for. > > SIGQUIT could be a valid option, or the super generic SIGUSR1 > > Regards, > Daniel Thanks for your answer Daniel. OK for not using SIGHUP and keep SIGTERM, SIGINT and SIGHUP to have the same behavior. SIGQUIT is reserved for core files generation. SIGUSR1 is already used in 'util/qemu-progress.c' to trigger a report on ongoing jobs, so it does not seem usable. SIGUSR2 is temporarily used in 'util/coroutine-sigaltstack.c' which takes care however to preserve the original handler. I did not saw any other place where it is used, so it seems to be a better candidate. Here is a second version of my patch using SIGUSR2 to cleanly power off the guest: Signed-off-by: Simon Geusebroek --- -- diff -ru qemu-2.8.0/os-posix.c qemu-new/os-posix.c --- qemu-2.8.0/os-posix.c 2016-12-20 21:16:48.000000000 +0100 +++ qemu-new/os-posix.c 2017-03-15 17:45:28.290737575 +0100 @@ -72,6 +72,7 @@ sigaction(SIGINT, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGTERM, &act, NULL); + sigaction(SIGUSR2, &act, NULL); } /* Find a likely location for support files using the location of the binary. diff -ru qemu-2.8.0/vl.c qemu-new/vl.c --- qemu-2.8.0/vl.c 2016-12-20 21:16:54.000000000 +0100 +++ qemu-new/vl.c 2017-03-15 17:45:20.866737459 +0100 @@ -1871,7 +1871,11 @@ /* Cannot call qemu_system_shutdown_request directly because * we are in a signal handler. */ - shutdown_requested = 1; + if (signal == SIGUSR2) { + powerdown_requested = 1; + } else { + shutdown_requested = 1; + } qemu_notify_event(); }