From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lmc13-00028W-3X for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:56:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lmc0x-0001yy-9a for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:56:07 -0400 Received: from [199.232.76.173] (port=49789 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lmc0w-0001yj-0V for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:56:02 -0400 Received: from mx2.redhat.com ([66.187.237.31]:51075) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lmc0v-0006Hm-CZ for qemu-devel@nongnu.org; Wed, 25 Mar 2009 18:56:01 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2PMu0nU032455 for ; Wed, 25 Mar 2009 18:56:00 -0400 Message-Id: <20090325225439.202882068@amt.cnet> Date: Wed, 25 Mar 2009 19:47:21 -0300 From: Marcelo Tosatti References: <20090325224714.853788328@amt.cnet> Content-Disposition: inline; filename=move-machine-events-to-iothread-2 Subject: [Qemu-devel] [patch 07/10] qemu: handle reset/poweroff/shutdown in iothread Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Marcelo Tosatti Its simpler to handle these events from only one context. Signed-off-by: Marcelo Tosatti Index: trunk/vl.c =================================================================== --- trunk.orig/vl.c +++ trunk/vl.c @@ -4030,25 +4030,6 @@ static void *cpu_main_loop(void *arg) } cur_cpu = env; - if (shutdown_requested) { - ret = EXCP_INTERRUPT; - if (no_shutdown) { - vm_stop(0); - no_shutdown = 0; - } - else - break; - } - if (reset_requested) { - reset_requested = 0; - qemu_system_reset(); - ret = EXCP_INTERRUPT; - } - if (powerdown_requested) { - powerdown_requested = 0; - qemu_system_powerdown(); - ret = EXCP_INTERRUPT; - } if (unlikely(ret == EXCP_DEBUG)) { gdb_set_stop_cpu(cur_cpu); vm_stop(EXCP_DEBUG); @@ -4097,10 +4078,6 @@ static void *cpu_main_loop(void *arg) } } else { env = env->next_cpu ?: first_cpu; - if (shutdown_requested) { - ret = EXCP_INTERRUPT; - break; - } timeout = 5000; } #ifdef CONFIG_PROFILER @@ -4151,8 +4128,18 @@ static void main_loop(void) qemu_system_ready = 1; qemu_cond_broadcast(&qemu_system_cond); - while (1) + while (1) { main_loop_wait(1000); + if (qemu_shutdown_requested()) { + if (no_shutdown) + no_shutdown = 0; + else + break; + } else if (qemu_powerdown_requested()) + qemu_system_powerdown(); + else if (qemu_reset_requested()) + qemu_system_reset(); + } } static void help(int exitcode)