Blame SOURCES/kvm-virtiofsd-use-g_date_time_get_microsecond-to-get-sub.patch

0bd2bb
From c4cc9d30f656acb7fcdc4d3a4b4a9bb0a34aaf7d Mon Sep 17 00:00:00 2001
0bd2bb
From: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
0bd2bb
Date: Thu, 18 Aug 2022 14:46:19 -0400
0bd2bb
Subject: [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
0bd2bb
0bd2bb
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
0bd2bb
RH-MergeRequest: 223: 8.7.z: virtiofsd: use g_date_time_get_microsecond to get subsecond
0bd2bb
RH-Bugzilla: 2132391
0bd2bb
RH-Acked-by: German Maglione <None>
0bd2bb
RH-Acked-by: Jano Tomko <None>
0bd2bb
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0bd2bb
RH-Commit: [1/1] bf1fe2785996ee9799ae23cc117598517749336c
0bd2bb
0bd2bb
The "%f" specifier in g_date_time_format() is only available in glib
0bd2bb
2.65.2 or later. If combined with older glib, the function returns null
0bd2bb
and the timestamp displayed as "(null)".
0bd2bb
0bd2bb
For backward compatibility, g_date_time_get_microsecond should be used
0bd2bb
to retrieve subsecond.
0bd2bb
0bd2bb
In this patch the g_date_time_format() leaves subsecond field as "%06d"
0bd2bb
and let next snprintf to format with g_date_time_get_microsecond.
0bd2bb
0bd2bb
Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
0bd2bb
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
0bd2bb
Message-id: 20220818184618.2205172-1-yokada.996@gmail.com
0bd2bb
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0bd2bb
(cherry picked from commit f16d15c9276bd8f501f861c39cbd4adc812d0c1d)
0bd2bb
---
0bd2bb
 tools/virtiofsd/passthrough_ll.c | 7 +++++--
0bd2bb
 1 file changed, 5 insertions(+), 2 deletions(-)
0bd2bb
0bd2bb
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
0bd2bb
index b3d0674f6d..523d8fbe1e 100644
0bd2bb
--- a/tools/virtiofsd/passthrough_ll.c
0bd2bb
+++ b/tools/virtiofsd/passthrough_ll.c
0bd2bb
@@ -3791,6 +3791,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
0bd2bb
 static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
0bd2bb
 {
0bd2bb
     g_autofree char *localfmt = NULL;
0bd2bb
+    char buf[64];
0bd2bb
 
0bd2bb
     if (current_log_level < level) {
0bd2bb
         return;
0bd2bb
@@ -3803,9 +3804,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
0bd2bb
                                        fmt);
0bd2bb
         } else {
0bd2bb
             g_autoptr(GDateTime) now = g_date_time_new_now_utc();
0bd2bb
-            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
0bd2bb
+            g_autofree char *nowstr = g_date_time_format(now,
0bd2bb
+                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
0bd2bb
+            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
0bd2bb
             localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
0bd2bb
-                                       nowstr, syscall(__NR_gettid), fmt);
0bd2bb
+                                       buf, syscall(__NR_gettid), fmt);
0bd2bb
         }
0bd2bb
         fmt = localfmt;
0bd2bb
     }
0bd2bb
-- 
0bd2bb
2.31.1
0bd2bb