thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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