From patchwork Wed Feb 20 15:32:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 222160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 648192C0079 for ; Thu, 21 Feb 2013 09:55:07 +1100 (EST) Received: from localhost ([::1]:45842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bgl-0001OP-0n for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 10:34:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfl-0007nR-EP for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8Bfj-0001ko-I1 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:29 -0500 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:56515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfj-0001kd-0X for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:27 -0500 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Feb 2013 21:01:24 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp05.in.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Feb 2013 21:01:22 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id C67A53940053 for ; Wed, 20 Feb 2013 21:03:22 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1KFXIH421430272 for ; Wed, 20 Feb 2013 21:03:19 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1KFXM8L025020 for ; Thu, 21 Feb 2013 02:33:22 +1100 Received: from titi.austin.rr.com (sig-9-76-138-226.mts.ibm.com [9.76.138.226]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1KFWpJR022744; Thu, 21 Feb 2013 02:33:19 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 09:32:48 -0600 Message-Id: <1361374369-19024-9-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1361374369-19024-1-git-send-email-aliguori@us.ibm.com> References: <1361374369-19024-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13022015-8256-0000-0000-0000064AD61A X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.5 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka , Stefano Stabellini Subject: [Qemu-devel] [PATCH 8/9] main-loop: refactor qemu_system_powerdown_request 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 Signed-off-by: Anthony Liguori --- vl.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/vl.c b/vl.c index a5805ec..39b2a5c 100644 --- a/vl.c +++ b/vl.c @@ -1698,7 +1698,6 @@ static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = QTAILQ_HEAD_INITIALIZER(reset_handlers); static int shutdown_signal = -1; static pid_t shutdown_pid; -static int powerdown_requested; static NotifierList powerdown_notifiers = NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); static NotifierList suspend_notifiers = @@ -1757,13 +1756,6 @@ static gboolean qemu_wakeup(gpointer unused) return FALSE; } -static int qemu_powerdown_requested(void) -{ - int r = powerdown_requested; - powerdown_requested = 0; - return r; -} - /* We use RUN_STATE_MAX but any invalid value will do */ static bool qemu_vmstop_requested(RunState *r) { @@ -1907,16 +1899,16 @@ void qemu_system_shutdown_request(void) g_idle_add(qemu_system_shutdown, NULL); } -static void qemu_system_powerdown(void) +static gboolean qemu_system_powerdown(gpointer unused) { monitor_protocol_event(QEVENT_POWERDOWN, NULL); notifier_list_notify(&powerdown_notifiers, NULL); + return FALSE; } void qemu_system_powerdown_request(void) { - powerdown_requested = 1; - qemu_notify_event(); + g_idle_add(qemu_system_powerdown, NULL); } void qemu_register_powerdown_notifier(Notifier *notifier) @@ -1944,9 +1936,6 @@ void qemu_system_vmstop_request(RunState state) static void main_loop_junk(void) { RunState r; - if (qemu_powerdown_requested()) { - qemu_system_powerdown(); - } if (qemu_vmstop_requested(&r)) { vm_stop(r); }