]> git.proxmox.com Git - qemu.git/blobdiff - cpus.c
qemu-iotests: filter QEMU_PROG in 051.out
[qemu.git] / cpus.c
diff --git a/cpus.c b/cpus.c
index e919dd7fb6e6d5a017a688116056b1320be7af6a..97e9ab4c077aa65de300cd44b5330ac5ec09c270 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -862,9 +862,29 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
     }
 #else /* _WIN32 */
     if (!qemu_cpu_is_self(cpu)) {
-        SuspendThread(cpu->hThread);
+        CONTEXT tcgContext;
+
+        if (SuspendThread(cpu->hThread) == (DWORD)-1) {
+            fprintf(stderr, "qemu:%s: GetLastError:%d\n", __func__,
+                    GetLastError());
+            exit(1);
+        }
+
+        /* On multi-core systems, we are not sure that the thread is actually
+         * suspended until we can get the context.
+         */
+        tcgContext.ContextFlags = CONTEXT_CONTROL;
+        while (GetThreadContext(cpu->hThread, &tcgContext) != 0) {
+            continue;
+        }
+
         cpu_signal(0);
-        ResumeThread(cpu->hThread);
+
+        if (ResumeThread(cpu->hThread) == (DWORD)-1) {
+            fprintf(stderr, "qemu:%s: GetLastError:%d\n", __func__,
+                    GetLastError());
+            exit(1);
+        }
     }
 #endif
 }