qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Weil <sw@weilnetz.de>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] vl: prevent SDL replacing 'main' on win32 platforms
Date: Thu, 13 Aug 2015 15:37:11 +0100	[thread overview]
Message-ID: <1439476631-23883-1-git-send-email-berrange@redhat.com> (raw)

The SDL provided 'main' replacement on Win32 redirects
stdout and stderr to text files, which in turn prevents
QEMU from using the console for the monitor (eg -monitor
stdio breaks), and also hides error messages and -help
output from the user.

Block SDL's replacement by simply undefining the 'main'
macro, so the QEMU binaries' 'main' symbol takes priority
over that found in SDL.dll

The SDL replacement is left in place for other platforms,
since it might be doing something more important on
them. It would be worth investigating if it can be removed
for OS-X though as a future cleanup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 vl.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 0adbbd6..bb9ed8b 100644
--- a/vl.c
+++ b/vl.c
@@ -39,7 +39,23 @@
 #endif
 
 #ifdef CONFIG_SDL
-#if defined(__APPLE__) || defined(main)
+#if defined(_WIN32)
+/*
+ * On Win32 SDL tries to rename 'main' to 'SDL_main' so it can
+ * insert itself into the startup sequence, by passing the
+ * compiler flag -Dmain=SDL_main. It does this so it can mess
+ * with startup, amongst other dubious things, replacing stdout
+ * and stderr with streams pointing to a file instead of the
+ * console. This in turn breaks ability of QEMU to use stdio for
+ * things like the monitor (eg no more -monitor stdio), and error
+ * reporting, even if SDL is not the current UI frontend.
+ *
+ * The SDL startup hacks appear to not be critical to the correct
+ * functioning of SDL on Win32, so block SDL's attempt to hijack
+ * 'main' and thus avoid broken console I/O
+ */
+#undef main
+#elif defined(__APPLE__) || defined(main)
 #include <SDL.h>
 int qemu_main(int argc, char **argv, char **envp);
 int main(int argc, char **argv)
-- 
2.4.3

             reply	other threads:[~2015-08-13 14:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 14:37 Daniel P. Berrange [this message]
2015-08-14 12:43 ` [Qemu-devel] [PATCH] vl: redirect stdio to a file in Windows GUI build Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439476631-23883-1-git-send-email-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).