diff mbox

[02/49] log: do not use CONFIG_USER_ONLY

Message ID 1458125219-131698-3-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini March 16, 2016, 10:46 a.m. UTC
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(-)
diff mbox

Patch

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 287ec1d..c83b43f 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -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;
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 40c24fd..1e59720 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -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);
 
diff --git a/linux-user/main.c b/linux-user/main.c
index 2b1e755..63bef30 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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);
 }
 
diff --git a/util/log.c b/util/log.c
index 8b921de..9dc8158 100644
--- a/util/log.c
+++ b/util/log.c
@@ -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);