Skip to contentSkip to conversation

w32: Disable buffering for log file

PATCH Applied Stefan Weil 2 participants 2 messages Dec 3, 2011 – Dec 11, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w32: Disable buffering for log file

W32 does not support line buffering, but it supports unbuffered output.

Unbuffered output is better for writing to qemu.log than fully buffered output because it also shows the latest log messages when an application crash occurs.

---
 exec.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
exec.c +4 -2
index 6b92198..d8b2180 100644
@@ -1603,8 +1603,10 @@ void cpu_set_log(int log_flags)
             static char logfile_buf[4096];
             setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
         }
-#elif !defined(_WIN32)
-        /* Win32 doesn't support line-buffering and requires size >= 2 */
+#elif defined(_WIN32)
+        /* Win32 doesn't support line-buffering, so use unbuffered output. */
+        setvbuf(logfile, NULL, _IONBF, 0);
+#else
         setvbuf(logfile, NULL, _IOLBF, 0);
 #endif
         log_append = 1;
Signature · 1 line
1.7.2.5
Applied
#1 lore raw

Thanks, applied.

Quoted 32 lines · Stefan Weil

W32 does not support line buffering, but it supports unbuffered output.

Unbuffered output is better for writing to qemu.log than fully buffered output because it also shows the latest log messages when an application crash occurs.

---
 exec.c |    6 ++++--

 1 files changed, 4 insertions(+), 2 deletions(-)
exec.c +4 -3
index 6b92198..d8b2180 100644
@@ -1603,8 +1603,10 @@ void cpu_set_log(int log_flags)
             static char logfile_buf[4096];
             setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
         }
-#elif !defined(_WIN32)
-        /* Win32 doesn't support line-buffering and requires size >= 2 */
+#elif defined(_WIN32)
+        /* Win32 doesn't support line-buffering, so use unbuffered output. */
+        setvbuf(logfile, NULL, _IONBF, 0);
+#else
         setvbuf(logfile, NULL, _IOLBF, 0);
  #endif
         log_append = 1;
--

1.7.2.5