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

97168e
From ebf6be5ba316ffda354af5eb1f1241ad6543b3cd 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
97168e
Subject: [PATCH 3/3] virtiofsd: use g_date_time_get_microsecond to get
97168e
 subsecond
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
0bd2bb
0bd2bb
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
97168e
RH-MergeRequest: 222: virtiofsd: use g_date_time_get_microsecond to get subsecond
97168e
RH-Bugzilla: 2018885
97168e
RH-Acked-by: Vivek Goyal <None>
97168e
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
97168e
RH-Acked-by: Sergio Lopez <slp@redhat.com>
97168e
RH-Commit: [1/1] da8795576acc7029044a801ef42676d66471a577
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
-- 
97168e
2.35.3
0bd2bb