@@ -848,6 +848,7 @@ int main(int argc, char **argv)
}
/* init debug */
+ qemu_log_needs_buffers();
qemu_set_log_filename(log_file);
if (log_mask) {
int mask;
@@ -99,21 +99,8 @@ typedef struct QEMULogItem {
extern const QEMULogItem qemu_log_items[];
-/* This is the function that actually does the work of
- * changing the log level; it should only be accessed via
- * the qemu_set_log() wrapper.
- */
-void do_qemu_set_log(int log_flags, bool use_own_buffers);
-
-static inline void qemu_set_log(int log_flags)
-{
-#ifdef CONFIG_USER_ONLY
- do_qemu_set_log(log_flags, true);
-#else
- do_qemu_set_log(log_flags, false);
-#endif
-}
-
+void qemu_set_log(int log_flags);
+void qemu_log_needs_buffers(void);
void qemu_set_log_filename(const char *filename);
int qemu_str_to_log_mask(const char *str);
@@ -3752,6 +3752,7 @@ static void handle_arg_log(const char *arg)
qemu_print_log_usage(stdout);
exit(EXIT_FAILURE);
}
+ qemu_log_needs_buffers();
qemu_set_log(mask);
}
@@ -49,8 +49,10 @@ void qemu_log_mask(int mask, const char *fmt, ...)
va_end(ap);
}
+static bool log_uses_own_buffers;
+
/* enable or disable low levels log */
-void do_qemu_set_log(int log_flags, bool use_own_buffers)
+void qemu_set_log(int log_flags)
{
qemu_loglevel = log_flags;
#ifdef CONFIG_TRACE_LOG
@@ -77,7 +79,7 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
qemu_logfile = stderr;
}
/* must avoid mmap() usage of glibc by setting a buffer "by hand" */
- if (use_own_buffers) {
+ if (log_uses_own_buffers) {
static char logfile_buf[4096];
setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
@@ -97,6 +99,11 @@ void do_qemu_set_log(int log_flags, bool use_own_buffers)
}
}
+void qemu_log_needs_buffers(void)
+{
+ log_uses_own_buffers = true;
+}
+
void qemu_set_log_filename(const char *filename)
{
g_free(logfilename);
This decouples logging further from config-target.h Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- bsd-user/main.c | 1 + include/qemu/log.h | 17 ++--------------- linux-user/main.c | 1 + util/log.c | 11 +++++++++-- 4 files changed, 13 insertions(+), 17 deletions(-)