From: "Daniel P. Berrange" <berrange@redhat.com>
To: "Gonglei (Arei)" <arei.gonglei@huawei.com>
Cc: "Herongguang (Stephen)" <herongguang.he@huawei.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Huangpeng (Peter)" <peter.huangpeng@huawei.com>
Subject: Re: [Qemu-devel] [RFC] Can we convert UTC time to local time in Qemu
Date: Wed, 20 May 2015 10:00:43 +0100 [thread overview]
Message-ID: <20150520090043.GD23989@redhat.com> (raw)
In-Reply-To: <33183CC9F5247A488A2544077AF1902086E86BFF@SZXEMA503-MBS.china.huawei.com>
On Wed, May 20, 2015 at 06:29:55AM +0000, Gonglei (Arei) wrote:
> Hi,
>
> At present, Qemu use g_time_val_to_iso8601() to get the UTC added to error_report()
> (commit 5e2ac5191), TBH this way is very simply, we just need invoke standard glib functions to
> complete the job.
>
> But in the cloud computing and data center scenarios, there are many
> Other open source components, such as kernel, libvirt, openstack which are all using local time
> to record the message logs, only Qemu is using the UTC time. When we want to find a error
> message of Qemu, we should convert the UTC time to local time manually, and unfortunately
> different countries have different local time, what a trouble thing the converting is.
>
> So, my question is: Can we convert the UTC time to local time in Qemu?
>
> Any thoughts? Thanks.
Actually, libvirt uses UTC for logging almost exclusively for quite a
while, because AFAIK, there is no async signal safe way to convert to
localtime in POSIX / glibc
commit 3ec128989606278635a7c5dfbeee959692d12e15
Author: Daniel P. Berrange <berrange@redhat.com>
Date: Tue Nov 29 12:11:01 2011 +0000
Add internal APIs for dealing with time
The logging APIs need to be able to generate formatted timestamps
using only async signal safe functions. This rules out using
gmtime/localtime/malloc/gettimeday(!) and much more.
Introduce a new internal API which is async signal safe.
virTimeMillisNowRaw replacement for gettimeofday. Uses clock_gettime
where available, otherwise falls back to the unsafe
gettimeofday
virTimeFieldsNowRaw replacements for gmtime(), convert a timestamp
virTimeFieldsThenRaw into a broken out set of fields. No localtime()
replacement is provided, because converting to
local time is not practical with only async signal
safe APIs.
virTimeStringNowRaw replacements for strftime() which print a timestamp
virTimeStringThenRaw into a string, using a pre-determined format, with
a fixed size buffer (VIR_TIME_STRING_BUFLEN)
For each of these there is also a version without the Raw postfix
which raises a full libvirt error. These versions are not async
signal safe
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
next prev parent reply other threads:[~2015-05-20 9:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 6:29 [Qemu-devel] [RFC] Can we convert UTC time to local time in Qemu Gonglei (Arei)
2015-05-20 9:00 ` Daniel P. Berrange [this message]
2015-05-20 9:28 ` Gonglei
2015-05-20 14:43 ` Eric Blake
2015-05-21 2:10 ` Gonglei
2015-05-21 3:04 ` Eric Blake
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=20150520090043.GD23989@redhat.com \
--to=berrange@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=herongguang.he@huawei.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.