From patchwork Fri Jun 4 13:24:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 54586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 21C86B7D1A for ; Sat, 5 Jun 2010 00:16:34 +1000 (EST) Received: from localhost ([127.0.0.1]:38303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKXhG-0007Ci-85 for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 10:16:30 -0400 Received: from [140.186.70.92] (port=47184 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKWug-0005lW-9Y for qemu-devel@nongnu.org; Fri, 04 Jun 2010 09:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKWtU-0001nL-9z for qemu-devel@nongnu.org; Fri, 04 Jun 2010 09:25:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41808) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKWtU-0001n0-3F for qemu-devel@nongnu.org; Fri, 04 Jun 2010 09:25:04 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54DP25M002572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jun 2010 09:25:02 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54DOm6V005003; Fri, 4 Jun 2010 09:25:01 -0400 From: Jes.Sorensen@redhat.com To: anthony@codemonkey.ws Date: Fri, 4 Jun 2010 15:24:31 +0200 Message-Id: <1275657882-19268-9-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1275657882-19268-1-git-send-email-Jes.Sorensen@redhat.com> References: <1275657882-19268-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jes Sorensen , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 06/17] Move win32 early signal handling setup to os_setup_signal_handling() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Move win32 early signal handling setup to os_setup_signal_handling() Signed-off-by: Jes Sorensen --- os-win32.c | 29 +++++++++++++++++++++++++++++ vl.c | 30 ------------------------------ 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/os-win32.c b/os-win32.c index 1f7e28b..dfa90bc 100644 --- a/os-win32.c +++ b/os-win32.c @@ -152,3 +152,32 @@ void os_host_main_loop_wait(int *timeout) *timeout = 0; } + +static BOOL WINAPI qemu_ctrl_handler(DWORD type) +{ + exit(STATUS_CONTROL_C_EXIT); + return TRUE; +} + +void os_setup_signal_handling(void) +{ + /* Note: cpu_interrupt() is currently not SMP safe, so we force + QEMU to run on a single CPU */ + HANDLE h; + DWORD mask, smask; + int i; + + SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); + + h = GetCurrentProcess(); + if (GetProcessAffinityMask(h, &mask, &smask)) { + for(i = 0; i < 32; i++) { + if (mask & (1 << i)) + break; + } + if (i != 32) { + mask = 1 << i; + SetProcessAffinityMask(h, mask); + } + } +} diff --git a/vl.c b/vl.c index 7a46fee..f43456a 100644 --- a/vl.c +++ b/vl.c @@ -1986,14 +1986,6 @@ static int balloon_parse(const char *arg) return -1; } -#ifdef _WIN32 -static BOOL WINAPI qemu_ctrl_handler(DWORD type) -{ - exit(STATUS_CONTROL_C_EXIT); - return TRUE; -} -#endif - #ifndef _WIN32 static void termsig_handler(int signal) @@ -2459,29 +2451,7 @@ int main(int argc, char **argv, char **envp) qemu_cache_utils_init(envp); QLIST_INIT (&vm_change_state_head); -#ifndef _WIN32 os_setup_signal_handling(); -#else - SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); - /* Note: cpu_interrupt() is currently not SMP safe, so we force - QEMU to run on a single CPU */ - { - HANDLE h; - DWORD mask, smask; - int i; - h = GetCurrentProcess(); - if (GetProcessAffinityMask(h, &mask, &smask)) { - for(i = 0; i < 32; i++) { - if (mask & (1 << i)) - break; - } - if (i != 32) { - mask = 1 << i; - SetProcessAffinityMask(h, mask); - } - } - } -#endif module_call_init(MODULE_INIT_MACHINE); machine = find_default_machine();