From patchwork Wed Feb 20 15:32:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 222142 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 D4D4B2C0082 for ; Thu, 21 Feb 2013 07:08:34 +1100 (EST) Received: from localhost ([::1]:43924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8BgB-0000MT-Jn for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 10:33:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfz-0008SO-76 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8Bfs-0001n6-AL for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:42 -0500 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:47744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfr-0001mH-Qo for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:36 -0500 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Feb 2013 21:00:23 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Feb 2013 21:00:20 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 5BAB6125804F for ; Wed, 20 Feb 2013 21:04:16 +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 r1KFXRgF24707166 for ; Wed, 20 Feb 2013 21:03:27 +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 r1KFXSHp025462 for ; Thu, 21 Feb 2013 02:33:29 +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 r1KFWpJS022744; Thu, 21 Feb 2013 02:33:23 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 09:32:49 -0600 Message-Id: <1361374369-19024-10-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-5816-0000-0000-000006C247F1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.2 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka , Stefano Stabellini Subject: [Qemu-devel] [PATCH 9/9] main-loop: refactor qemu_system_vmstop_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 | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/vl.c b/vl.c index 39b2a5c..b9aa106 100644 --- a/vl.c +++ b/vl.c @@ -1705,7 +1705,6 @@ static NotifierList suspend_notifiers = static NotifierList wakeup_notifiers = NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); static uint32_t wakeup_reason_mask = ~0; -static RunState vmstop_requested = RUN_STATE_MAX; int qemu_shutdown_requested_get(void) { @@ -1756,18 +1755,6 @@ static gboolean qemu_wakeup(gpointer unused) return FALSE; } -/* We use RUN_STATE_MAX but any invalid value will do */ -static bool qemu_vmstop_requested(RunState *r) -{ - if (vmstop_requested < RUN_STATE_MAX) { - *r = vmstop_requested; - vmstop_requested = RUN_STATE_MAX; - return true; - } - - return false; -} - void qemu_register_reset(QEMUResetHandler *func, void *opaque) { QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry)); @@ -1927,18 +1914,16 @@ void qemu_system_debug_request(void) g_idle_add(qemu_system_debug, NULL); } -void qemu_system_vmstop_request(RunState state) +static gboolean qemu_system_vmstop(gpointer opaque) { - vmstop_requested = state; - qemu_notify_event(); + RunState r = (RunState)opaque; + vm_stop(r); + return FALSE; } -static void main_loop_junk(void) +void qemu_system_vmstop_request(RunState state) { - RunState r; - if (qemu_vmstop_requested(&r)) { - vm_stop(r); - } + g_idle_add(qemu_system_vmstop, (gpointer)state); } static void main_loop(void) @@ -1957,7 +1942,6 @@ static void main_loop(void) #ifdef CONFIG_PROFILER dev_time += profile_getclock() - ti; #endif - main_loop_junk(); } while (!main_loop_should_quit()); }