qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Fabianowski <bartosz@fabianowski.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Changing RTC from UTC to local time
Date: Sat, 29 May 2004 16:39:45 +0200	[thread overview]
Message-ID: <40B8A0B1.3040601@fabianowski.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

Hi

I have recently been experimenting with QEMU a bit and I noticed that 
the simulated RTC will always give the time in UTC, not in the local 
time zone of the host. This is probably by design; however, I would like 
to question that design choice.

On a PC, the RTC is supposed to always be set to local time, not to UTC. 
It might be different on different architectures - but for a simulated 
PC, the current behavior is not correct.

This is an important issue because Windows assumes that the RTC behaves 
to the spec and thinks that the time reported by the RTC is local. Thus, 
a Windows installed inside QEMU will report the current UTC time as the 
local time. If the host computer is located in any time zone other than 
GMT, the time on the host and the time on the slave will therefore be 
off by hours.

The fix for this is obvious - set the RTC to the local time of the host, 
not to UTC. I have attached a trivial patch to accomplish this.

Regards,
- Bartosz Fabianowski

[-- Attachment #2: local_time_patch.diff --]
[-- Type: text/plain, Size: 725 bytes --]

diff -rud qemu/hw/mc146818rtc.c qemu-patched/hw/mc146818rtc.c
--- qemu/hw/mc146818rtc.c	Sat Apr  3 14:27:31 2004
+++ qemu-patched/hw/mc146818rtc.c	Sat May 29 14:24:29 2004
@@ -235,7 +235,7 @@
     time_t ti;
 
     ti = s->current_time;
-    rtc_set_date_buf(s, gmtime(&ti));
+    rtc_set_date_buf(s, localtime(&ti));
 
     if (!(s->cmos_data[RTC_REG_B] & REG_B_SET)) {
         rtc_copy_date(s);
diff -rud qemu/hw/pc.c qemu-patched/hw/pc.c
--- qemu/hw/pc.c	Sun May 23 21:10:46 2004
+++ qemu-patched/hw/pc.c	Sat May 29 14:24:46 2004
@@ -110,7 +110,7 @@
 
     /* set the CMOS date */
     time(&ti);
-    tm = gmtime(&ti);
+    tm = localtime(&ti);
     rtc_set_date(s, tm);
 
     val = to_bcd(s, (tm->tm_year / 100) + 19);

             reply	other threads:[~2004-05-29 14:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-29 14:39 Bartosz Fabianowski [this message]
2004-05-29 17:23 ` [Qemu-devel] Changing RTC from UTC to local time Kyle Hayes
2004-05-29 18:50   ` Bartosz Fabianowski
2004-05-29 23:13     ` Tim
2004-05-29 23:23       ` Bartosz Fabianowski
2004-05-30  4:52         ` John R. Hogerhuis
2004-05-30 19:32           ` Bartosz Fabianowski
2004-05-30 19:42             ` Kyle Hayes
2004-05-31 13:53             ` Pavel Janík
2004-05-31 14:20               ` Bartosz Fabianowski
2004-05-31 14:51               ` Fabrice Bellard
2004-05-31 14:51                 ` Bartosz Fabianowski
2004-05-31 15:12                 ` Derek Fawcus
2004-05-31 16:43                   ` Tim
2004-05-31 16:27                 ` Pavel Janík
2004-05-31 17:09                 ` Kyle Hayes
2004-05-30 21:59     ` Flavien
2004-05-31  0:29       ` Bartosz Fabianowski
2004-05-31  1:52         ` Kyle Hayes
2004-05-31 12:11           ` Bartosz Fabianowski

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=40B8A0B1.3040601@fabianowski.de \
    --to=bartosz@fabianowski.de \
    --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 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 NNTP newsgroup(s).