From patchwork Wed Feb 20 15:32:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 222104 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 20CAD2C0077 for ; Thu, 21 Feb 2013 02:33:50 +1100 (EST) Received: from localhost ([::1]:42195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bg4-0007sY-28 for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 10:33:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfg-0007bQ-UF for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8Bfc-0001jG-Dd for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:24 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:43788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8Bfb-0001is-R9 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 10:33:20 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Feb 2013 20:59:53 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Feb 2013 20:59:53 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id D1340394004F for ; Wed, 20 Feb 2013 21:03:16 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1KFXCSQ36831460 for ; Wed, 20 Feb 2013 21:03:12 +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 r1KFXFvm024593 for ; Thu, 21 Feb 2013 02:33:16 +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 r1KFWpJP022744; Thu, 21 Feb 2013 02:33:13 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 09:32:46 -0600 Message-Id: <1361374369-19024-7-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-2000-0000-0000-00000B0561B4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: Paolo Bonzini , Anthony Liguori , Jan Kiszka , Stefano Stabellini Subject: [Qemu-devel] [PATCH 6/9] main-loop: refactor qemu_system_reset_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 N.B. no Signed-off-by because this breaks Xen --- vl.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/vl.c b/vl.c index 1a63986..27b6455 100644 --- a/vl.c +++ b/vl.c @@ -1696,7 +1696,6 @@ typedef struct QEMUResetEntry { static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = QTAILQ_HEAD_INITIALIZER(reset_handlers); -static int reset_requested; static int shutdown_signal = -1; static pid_t shutdown_pid; static int powerdown_requested; @@ -1717,7 +1716,7 @@ int qemu_shutdown_requested_get(void) int qemu_reset_requested_get(void) { - return reset_requested; + return 0; // FIXME } static void qemu_kill_report(void) @@ -1736,11 +1735,17 @@ static void qemu_kill_report(void) } } -static int qemu_reset_requested(void) +static gboolean qemu_reset(gpointer unused) { - int r = reset_requested; - reset_requested = 0; - return r; + pause_all_vcpus(); + cpu_synchronize_all_states(); + qemu_system_reset(VMRESET_REPORT); + resume_all_vcpus(); + if (runstate_check(RUN_STATE_INTERNAL_ERROR) || + runstate_check(RUN_STATE_SHUTDOWN)) { + runstate_set(RUN_STATE_PAUSED); + } + return FALSE; } static int qemu_wakeup_requested(void) @@ -1819,9 +1824,8 @@ void qemu_system_reset_request(void) if (no_reboot) { qemu_system_shutdown_request(); } else { - reset_requested = 1; cpu_stop_current(); - qemu_notify_event(); + g_idle_add(qemu_reset, NULL); } } @@ -1939,16 +1943,6 @@ void qemu_system_vmstop_request(RunState state) static void main_loop_junk(void) { RunState r; - if (qemu_reset_requested()) { - pause_all_vcpus(); - cpu_synchronize_all_states(); - qemu_system_reset(VMRESET_REPORT); - resume_all_vcpus(); - if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { - runstate_set(RUN_STATE_PAUSED); - } - } if (qemu_wakeup_requested()) { pause_all_vcpus(); cpu_synchronize_all_states();