aboutsummaryrefslogtreecommitdiff
path: root/os-win32.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-06-10 11:42:20 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-06-12 08:49:14 +0300
commit69bd73b1b027f56ad68ac83aa5628c89fa05c10f (patch)
treef07c5f9ac576ccd0d5d113e530677a308b84e58f /os-win32.c
parent86b645e753b9396f8cc5b74a9eadf2d36f76ae5c (diff)
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 <Jes.Sorensen@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Acked-by: Richard Henderson <rth@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'os-win32.c')
-rw-r--r--os-win32.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/os-win32.c b/os-win32.c
index 1f7e28bad2..dfa90bce6a 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);
+ }
+ }
+}