From patchwork Wed Feb 20 15:32:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 222114 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 BF21C2C007B for ; Thu, 21 Feb 2013 03:23:37 +1100 (EST) Received: from localhost ([::1]:46238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bgs-0001bL-1V for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 10:34:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfl-0007pc-Tq for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8Bfh-0001kT-6Q for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:29 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:60479) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfg-0001jn-Mc for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:25 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Feb 2013 21:00:53 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Feb 2013 21:00:50 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 1D5E2125804E for ; Wed, 20 Feb 2013 21:04:06 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1KFXGTg31719528 for ; Wed, 20 Feb 2013 21:03:16 +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 r1KFXIXI024778 for ; Thu, 21 Feb 2013 02:33:18 +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 r1KFWpJQ022744; Thu, 21 Feb 2013 02:33:16 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 09:32:47 -0600 Message-Id: <1361374369-19024-8-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-5564-0000-0000-000006B0ADE8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.4 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka , Stefano Stabellini Subject: [Qemu-devel] [PATCH 7/9] main-loop: refactor qemu_system_wakeup_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 | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/vl.c b/vl.c index 27b6455..a5805ec 100644 --- a/vl.c +++ b/vl.c @@ -1699,7 +1699,6 @@ static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = static int shutdown_signal = -1; static pid_t shutdown_pid; static int powerdown_requested; -static int wakeup_requested; static NotifierList powerdown_notifiers = NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); static NotifierList suspend_notifiers = @@ -1748,11 +1747,14 @@ static gboolean qemu_reset(gpointer unused) return FALSE; } -static int qemu_wakeup_requested(void) +static gboolean qemu_wakeup(gpointer unused) { - int r = wakeup_requested; - wakeup_requested = 0; - return r; + pause_all_vcpus(); + cpu_synchronize_all_states(); + qemu_system_reset(VMRESET_SILENT); + resume_all_vcpus(); + monitor_protocol_event(QEVENT_WAKEUP, NULL); + return FALSE; } static int qemu_powerdown_requested(void) @@ -1862,8 +1864,7 @@ void qemu_system_wakeup_request(WakeupReason reason) } runstate_set(RUN_STATE_RUNNING); notifier_list_notify(&wakeup_notifiers, &reason); - wakeup_requested = 1; - qemu_notify_event(); + g_idle_add(qemu_wakeup, NULL); } void qemu_system_wakeup_enable(WakeupReason reason, bool enabled) @@ -1943,13 +1944,6 @@ void qemu_system_vmstop_request(RunState state) static void main_loop_junk(void) { RunState r; - if (qemu_wakeup_requested()) { - pause_all_vcpus(); - cpu_synchronize_all_states(); - qemu_system_reset(VMRESET_SILENT); - resume_all_vcpus(); - monitor_protocol_event(QEVENT_WAKEUP, NULL); - } if (qemu_powerdown_requested()) { qemu_system_powerdown(); }