qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] main-loop: Fix SetEvent() on uninitialized handle on win32
@ 2012-01-21  1:08 Michael Roth
  2012-01-21  7:49 ` Paolo Bonzini
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Michael Roth @ 2012-01-21  1:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, pbonzini, mdroth

The __attribute__((constructor)) init_main_loop() automatically get
called if qemu-tool.o is linked in. On win32, this leads to
a qemu_notify_event() call which attempts to SetEvent() on a HANDLE that
won't be initialized until qemu_init_main_loop() is manually called,
breaking qemu-tools.o programs on Windows at runtime.

This patch checks for an initialized event handle before attempting to
set it, which is analoguous to how we deal with an unitialized
io_thread_fd in the posix implementation.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 main-loop.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/main-loop.c b/main-loop.c
index 692381c..62d95b9 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -164,7 +164,7 @@ static int qemu_signal_init(void)
 
 #else /* _WIN32 */
 
-HANDLE qemu_event_handle;
+HANDLE qemu_event_handle = NULL;
 
 static void dummy_event_handler(void *opaque)
 {
@@ -183,6 +183,9 @@ static int qemu_event_init(void)
 
 void qemu_notify_event(void)
 {
+    if (!qemu_event_handle) {
+        return;
+    }
     if (!SetEvent(qemu_event_handle)) {
         fprintf(stderr, "qemu_notify_event: SetEvent failed: %ld\n",
                 GetLastError());
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-02-01 22:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-21  1:08 [Qemu-devel] [PATCH] main-loop: Fix SetEvent() on uninitialized handle on win32 Michael Roth
2012-01-21  7:49 ` Paolo Bonzini
2012-01-21 17:13 ` [Qemu-devel] [PATCH] main-loop: For tools, initialize timers as part of qemu_init_main_loop() Michael Roth
2012-01-21 20:39   ` Jamie Lokier
2012-01-22 12:32     ` Paolo Bonzini
2012-01-23  0:12       ` Michael Roth
2012-01-23  7:49         ` Paolo Bonzini
2012-01-27  5:46   ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2012-01-27  8:09     ` Paolo Bonzini
2012-01-27  5:46   ` Stefan Hajnoczi
2012-02-01 22:10   ` [Qemu-devel] " Anthony Liguori
2012-01-27  5:41 ` [Qemu-devel] [Qemu-trivial] [PATCH] main-loop: Fix SetEvent() on uninitialized handle on win32 Stefan Hajnoczi
2012-01-27 14:52   ` [Qemu-devel] [PATCH v2] " Michael Roth
2012-02-01 22:10 ` [Qemu-devel] [PATCH] " Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).