virtio-fs.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "liuyd.fnst@fujitsu.com" <liuyd.fnst@fujitsu.com>
To: Yusuke Okada <yokada.996@gmail.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "open list:virtiofs" <virtio-fs@redhat.com>,
	"okada.yusuke@fujitsu.com" <okada.yusuke@fujitsu.com>
Subject: Re: [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond
Date: Fri, 19 Aug 2022 01:47:21 +0000	[thread overview]
Message-ID: <402e7bce-46de-6d9e-5bad-045a42efa6ba@fujitsu.com> (raw)
In-Reply-To: <20220818174650.31360-1-okada.yusuke@jp.fujitsu.com>

It works. I tested on RHEL8
Before this fix:
```
# /root/qemu/build/tools/virtiofsd/virtiofsd --socket-path=/tmp/sock -o 
source=/home/test -d

[(null)] [ID: 00133152] virtio_session_mount: Waiting for vhost-user 
socket connection...


```

After applying this patch
```
# /root/qemu/build/tools/virtiofsd/virtiofsd --socket-path=/tmp/sock -o 
source=/home/test -d

[2022-08-19 01:45:41.981608+0000] [ID: 00134587] virtio_session_mount: 
Waiting for vhost-user socket connection...

```	


On 8/19/22 01:46, Yusuke Okada wrote:
> The "%f" specifier in g_date_time_format() is only available in glib
> 2.65.2 or later. If combined with older glib, the function returns null
> and the timestamp displayed as "(null)".
> 
> For backward compatibility, g_date_time_get_microsecond should be used
> to retrieve subsecond.
> 
> In this patch the g_date_time_format() leaves subsecond field as "%06d"
> and let next snprintf to format with g_date_time_get_microsecond.
> 
> Signed-off-by: Yusuke Okada <okada.yusuke@jp.fujitsu.com>
> ---
>   tools/virtiofsd/passthrough_ll.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 371a7bead6..20f0f41f99 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -4185,6 +4185,7 @@ static void setup_nofile_rlimit(unsigned long rlimit_nofile)
>   static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>   {
>       g_autofree char *localfmt = NULL;
> +    char buf[64];
>   
>       if (current_log_level < level) {
>           return;
> @@ -4197,9 +4198,11 @@ static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
>                                          fmt);
>           } else {
>               g_autoptr(GDateTime) now = g_date_time_new_now_utc();
> -            g_autofree char *nowstr = g_date_time_format(now, "%Y-%m-%d %H:%M:%S.%f%z");
> +            g_autofree char *nowstr = g_date_time_format(now,
> +                                       "%Y-%m-%d %H:%M:%S.%%06d%z");
> +            snprintf(buf, 64, nowstr, g_date_time_get_microsecond(now));
>               localfmt = g_strdup_printf("[%s] [ID: %08ld] %s",
> -                                       nowstr, syscall(__NR_gettid), fmt);
> +                                       buf, syscall(__NR_gettid), fmt);
>           }
>           fmt = localfmt;
>       }

-- 
Thanks,
Yiding

  reply	other threads:[~2022-08-19  1:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 17:46 [Virtio-fs] [PATCH] virtiofsd: use g_date_time_get_microsecond to get subsecond Yusuke Okada
2022-08-19  1:47 ` liuyd.fnst [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-08-18 18:46 Yusuke Okada
2022-08-18 19:12 ` okada.yusuke
2022-08-24 11:05 ` Dr. David Alan Gilbert
2022-08-24 17:41 ` Stefan Hajnoczi
2022-09-20 17:58   ` Vivek Goyal
2022-09-27 15:50     ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=402e7bce-46de-6d9e-5bad-045a42efa6ba@fujitsu.com \
    --to=liuyd.fnst@fujitsu.com \
    --cc=okada.yusuke@fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=virtio-fs@redhat.com \
    --cc=yokada.996@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).