cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-Add-timestamp-to-the-log-with-FUSE_LOG_DEB.patch

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