qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Changing RTC from UTC to local time
@ 2004-05-29 14:39 Bartosz Fabianowski
  2004-05-29 17:23 ` Kyle Hayes
  0 siblings, 1 reply; 20+ messages in thread
From: Bartosz Fabianowski @ 2004-05-29 14:39 UTC (permalink / raw)
  To: qemu-devel

[-- 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);

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2004-05-31 19:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-29 14:39 [Qemu-devel] Changing RTC from UTC to local time Bartosz Fabianowski
2004-05-29 17:23 ` 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

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).