From 6000f7ff2290c9f0120b0e24036131d456d42765 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 7 Mar 2012 11:35:41 -0500 Subject: [PATCH 81/98] Move win32 early signal handling setup to os_setup_signal_handling() Move win32 early signal handling setup to os_setup_signal_handling() Signed-off-by: Jes Sorensen Acked-by: Juan Quintela Acked-by: Richard Henderson Signed-off-by: Blue Swirl (cherry picked from commit 69bd73b1b027f56ad68ac83aa5628c89fa05c10f) Conflicts: vl.c Signed-off-by: Jeff Cody Signed-off-by: Michal Novotny --- os-win32.c | 29 +++++++++++++++++++++++++++++ qemu-os-posix.h | 2 -- sysemu.h | 2 ++ vl.c | 29 ----------------------------- 4 files changed, 31 insertions(+), 31 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/qemu-os-posix.h b/qemu-os-posix.h index ff5adb1..96d1036 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -30,6 +30,4 @@ static inline void os_host_main_loop_wait(int *timeout) { } -void os_setup_signal_handling(void); - #endif diff --git a/sysemu.h b/sysemu.h index 72e38fb..49ed330 100644 --- a/sysemu.h +++ b/sysemu.h @@ -122,6 +122,8 @@ int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); +void os_setup_signal_handling(void); + typedef enum DisplayType { DT_DEFAULT, diff --git a/vl.c b/vl.c index 8295665..9894425 100644 --- a/vl.c +++ b/vl.c @@ -4541,13 +4541,6 @@ static int balloon_parse(const char *arg) } #endif -#ifdef _WIN32 -static BOOL WINAPI qemu_ctrl_handler(DWORD type) -{ - exit(STATUS_CONTROL_C_EXIT); - return TRUE; -} -#endif int qemu_uuid_parse(const char *str, uint8_t *uuid) { @@ -5048,29 +5041,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(); -- 1.7.7.6