From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LkJpI-0007th-Pn for qemu-devel@nongnu.org; Thu, 19 Mar 2009 11:06:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LkJpE-0007r6-1h for qemu-devel@nongnu.org; Thu, 19 Mar 2009 11:06:32 -0400 Received: from [199.232.76.173] (port=51968 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LkJpD-0007r1-UH for qemu-devel@nongnu.org; Thu, 19 Mar 2009 11:06:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36014) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LkJpD-0005wC-B3 for qemu-devel@nongnu.org; Thu, 19 Mar 2009 11:06:27 -0400 Message-Id: <20090319150538.147575572@localhost.localdomain> References: <20090319145705.988576615@localhost.localdomain> Date: Thu, 19 Mar 2009 11:57:09 -0300 From: mtosatti@redhat.com Content-Disposition: inline; filename=move-machine-events-to-iothread Subject: [Qemu-devel] [patch 4/7] 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 Its simpler to handle these events from only one context. Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c +++ qemu/vl.c @@ -3540,22 +3540,19 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } - if (cpu_single_env) - cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT); + main_loop_break(); } void qemu_system_shutdown_request(void) { shutdown_requested = 1; - if (cpu_single_env) - cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT); + main_loop_break(); } void qemu_system_powerdown_request(void) { powerdown_requested = 1; - if (cpu_single_env) - cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT); + main_loop_break(); } #ifdef _WIN32 @@ -3921,25 +3918,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); @@ -3987,10 +3965,6 @@ static void *cpu_main_loop(void *arg) timeout = 0; } } else { - if (shutdown_requested) { - ret = EXCP_INTERRUPT; - break; - } timeout = 5000; } #ifdef CONFIG_PROFILER @@ -4017,8 +3991,18 @@ static void main_loop(void) qemu_thread_create(&cpus_thread, cpu_main_loop, NULL); - 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) --