qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
@ 2009-07-27  8:02 Filip Navara
  2009-07-27 13:21 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Filip Navara @ 2009-07-27  8:02 UTC (permalink / raw)
  To: qemu-devel

On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them.

Signed-off-by: Filip Navara <filip.navara@gmail.com>
---
 exec.c |    3 ++-
 vl.c   |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index 7d3eb1a..ef79d6d 100644
--- a/exec.c
+++ b/exec.c
@@ -1491,7 +1491,8 @@ void cpu_set_log(int log_flags)
             static char logfile_buf[4096];
             setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
         }
-#else
+#elif !defined(_WIN32)
+        /* Win32 doesn't support line-buffering and requires size >= 2 */
         setvbuf(logfile, NULL, _IOLBF, 0);
 #endif
         log_append = 1;
diff --git a/vl.c b/vl.c
index ce213c2..d4e49e4 100644
--- a/vl.c
+++ b/vl.c
@@ -5735,7 +5735,10 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+#ifndef _WIN32
+    /* Win32 doesn't support line-buffering and requires size >= 2 */
     setvbuf(stdout, NULL, _IOLBF, 0);
+#endif
 
     init_timers();
     if (init_timer_alarm() < 0) {
-- 
1.6.3.2.1299.gee46c

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

* Re: [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
  2009-07-27  8:02 [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32 Filip Navara
@ 2009-07-27 13:21 ` Daniel Jacobowitz
  2009-07-27 13:33   ` Filip Navara
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2009-07-27 13:21 UTC (permalink / raw)
  To: Filip Navara; +Cc: qemu-devel

On Mon, Jul 27, 2009 at 10:02:04AM +0000, Filip Navara wrote:
> On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them.

Should they be unbuffered where _IOLBF is not supported, then?  I
assume the line buffering was to make them more useful in event of a
crash.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
  2009-07-27 13:21 ` Daniel Jacobowitz
@ 2009-07-27 13:33   ` Filip Navara
  2009-07-27 13:42     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Filip Navara @ 2009-07-27 13:33 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: qemu-devel

On Mon, Jul 27, 2009 at 3:21 PM, Daniel Jacobowitz<drow@false.org> wrote:
> On Mon, Jul 27, 2009 at 10:02:04AM +0000, Filip Navara wrote:
>> On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them.
>
> Should they be unbuffered where _IOLBF is not supported, then?  I
> assume the line buffering was to make them more useful in event of a
> crash.

I guess your assumption is correct. I'd be fine with using _IONBF for
the exec.c part, but setting it for stdout doesn't sound too useful to
me.

Best regards,
Filip Navara

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

* Re: [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
  2009-07-27 13:33   ` Filip Navara
@ 2009-07-27 13:42     ` Daniel Jacobowitz
  2009-07-27 14:25       ` Filip Navara
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2009-07-27 13:42 UTC (permalink / raw)
  To: Filip Navara; +Cc: qemu-devel

On Mon, Jul 27, 2009 at 03:33:08PM +0200, Filip Navara wrote:
> On Mon, Jul 27, 2009 at 3:21 PM, Daniel Jacobowitz<drow@false.org> wrote:
> > On Mon, Jul 27, 2009 at 10:02:04AM +0000, Filip Navara wrote:
> >> On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them.
> >
> > Should they be unbuffered where _IOLBF is not supported, then?  I
> > assume the line buffering was to make them more useful in event of a
> > crash.
> 
> I guess your assumption is correct. I'd be fine with using _IONBF for
> the exec.c part, but setting it for stdout doesn't sound too useful to
> me.

I've found that leaving stdout buffered on Windows is a pain; on Unix
"isatty()" is reliable, but on Windows it breaks down at the
Cygwin/Windows interaction border.  So your simulated programs end up
using block output all the time if you have a mingw32 qemu in a Cygwin
terminal, for instance.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
  2009-07-27 13:42     ` Daniel Jacobowitz
@ 2009-07-27 14:25       ` Filip Navara
  2009-07-27 14:32         ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Filip Navara @ 2009-07-27 14:25 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]

On Mon, Jul 27, 2009 at 3:42 PM, Daniel Jacobowitz <drow@false.org> wrote:

> On Mon, Jul 27, 2009 at 03:33:08PM +0200, Filip Navara wrote:
> > On Mon, Jul 27, 2009 at 3:21 PM, Daniel Jacobowitz<drow@false.org>
> wrote:
> > > On Mon, Jul 27, 2009 at 10:02:04AM +0000, Filip Navara wrote:
> > >> On Win32 the setvbuf function requires the last parameter to be size
> between 2 and INT_MAX bytes, so the calls always failed. Since the whole
> point of the calls is to set line-buffered mode for the file handle and
> that's not supported on Win32 anyway, conditionally remove them.
> > >
> > > Should they be unbuffered where _IOLBF is not supported, then?  I
> > > assume the line buffering was to make them more useful in event of a
> > > crash.
> >
> > I guess your assumption is correct. I'd be fine with using _IONBF for
> > the exec.c part, but setting it for stdout doesn't sound too useful to
> > me.
>
> I've found that leaving stdout buffered on Windows is a pain; on Unix
> "isatty()" is reliable, but on Windows it breaks down at the
> Cygwin/Windows interaction border.  So your simulated programs end up
> using block output all the time if you have a mingw32 qemu in a Cygwin
> terminal, for instance.


I use MinGW-built QEMU in regular command line and MSYS sh and I never had a
single problem with the buffering. I can't speak for Cygwin, but if they
can't get it right I don't think it's up to QEMU to fix it (heck, checking
for a console handle is as easy as "(handle & 3) != 0").

The log files are different story, since for certain types of crashes the
last block is lost. Since log files are actually used for debugging problems
I acknowledge that keeping the content is important.

Best regards,
Filip Navara

[-- Attachment #2: Type: text/html, Size: 2274 bytes --]

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

* Re: [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32
  2009-07-27 14:25       ` Filip Navara
@ 2009-07-27 14:32         ` Daniel Jacobowitz
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2009-07-27 14:32 UTC (permalink / raw)
  To: Filip Navara; +Cc: qemu-devel

On Mon, Jul 27, 2009 at 04:25:32PM +0200, Filip Navara wrote:
> I use MinGW-built QEMU in regular command line and MSYS sh and I never had a
> single problem with the buffering. I can't speak for Cygwin, but if they
> can't get it right I don't think it's up to QEMU to fix it (heck, checking
> for a console handle is as easy as "(handle & 3) != 0").

It is not a Cygwin problem.  It's a MSVCRT runtime problem.  The
runtime checks isatty to determine the buffering of stdout (this is a
standard C thing to do), and Cygwin terminals do not show up as
consoles.

If the underlying device is really a Windows console, of course,
there's no problem.  But Cygwin SSH ptys, for example, are not
Windows consoles.

-- 
Daniel Jacobowitz
CodeSourcery

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

end of thread, other threads:[~2009-07-27 14:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-27  8:02 [Qemu-devel] [PATCH 3/5] Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32 Filip Navara
2009-07-27 13:21 ` Daniel Jacobowitz
2009-07-27 13:33   ` Filip Navara
2009-07-27 13:42     ` Daniel Jacobowitz
2009-07-27 14:25       ` Filip Navara
2009-07-27 14:32         ` Daniel Jacobowitz

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).