render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0070-virtiofsd-Add-timestamp-to-the-log-with-FUSE_LOG_DEB.patch

1d442b
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
1d442b
Date: Mon, 27 Jan 2020 19:01:39 +0000
1d442b
Subject: [PATCH] virtiofsd: Add timestamp to the log with FUSE_LOG_DEBUG level
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
virtiofsd has some threads, so we see a lot of logs with debug option.
1d442b
It would be useful for debugging if we can see the timestamp.
1d442b
1d442b
Add nano second timestamp, which got by get_clock(), to the log with
1d442b
FUSE_LOG_DEBUG level if the syslog option isn't set.
1d442b
1d442b
The log is like as:
1d442b
1d442b
  # ./virtiofsd -d -o vhost_user_socket=/tmp/vhostqemu0 -o source=/tmp/share0 -o cache=auto
1d442b
  ...
1d442b
  [5365943125463727] [ID: 00000002] fv_queue_thread: Start for queue 0 kick_fd 9
1d442b
  [5365943125568644] [ID: 00000002] fv_queue_thread: Waiting for Queue 0 event
1d442b
  [5365943125573561] [ID: 00000002] fv_queue_thread: Got queue event on Queue 0
1d442b
1d442b
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
1d442b
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit 50fb955aa0e6ede929422146936cf68bf1ca876f)
1d442b
---
1d442b
 tools/virtiofsd/passthrough_ll.c | 9 ++++++++-
1d442b
 1 file changed, 8 insertions(+), 1 deletion(-)
1d442b
1d442b
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
1d442b
index f08324f000..98114a3f4a 100644
1d442b
--- a/tools/virtiofsd/passthrough_ll.c
1d442b
+++ b/tools/virtiofsd/passthrough_ll.c
1d442b
@@ -36,6 +36,7 @@
1d442b
  */
1d442b
 
1d442b
 #include "qemu/osdep.h"
1d442b
+#include "qemu/timer.h"
1d442b
 #include "fuse_virtio.h"
1d442b
 #include "fuse_log.h"
1d442b
 #include "fuse_lowlevel.h"
1d442b
@@ -2276,7 +2277,13 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
1d442b
     }
1d442b
 
1d442b
     if (current_log_level == FUSE_LOG_DEBUG) {
1d442b
-        localfmt = g_strdup_printf("[ID: %08ld] %s", syscall(__NR_gettid), fmt);
1d442b
+        if (!use_syslog) {
1d442b
+            localfmt = g_strdup_printf("[%" PRId64 "] [ID: %08ld] %s",
1d442b
+                                       get_clock(), syscall(__NR_gettid), fmt);
1d442b
+        } else {
1d442b
+            localfmt = g_strdup_printf("[ID: %08ld] %s", syscall(__NR_gettid),
1d442b
+                                       fmt);
1d442b
+        }
1d442b
         fmt = localfmt;
1d442b
     }
1d442b