[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Changing RTC from UTC to local time
From: |
Bartosz Fabianowski |
Subject: |
[Qemu-devel] Changing RTC from UTC to local time |
Date: |
Sat, 29 May 2004 16:39:45 +0200 |
User-agent: |
Mozilla Thunderbird 0.6 (X11/20040517) |
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
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);
- [Qemu-devel] Changing RTC from UTC to local time,
Bartosz Fabianowski <=
- Re: [Qemu-devel] Changing RTC from UTC to local time, Kyle Hayes, 2004/05/29
- Re: [Qemu-devel] Changing RTC from UTC to local time, Bartosz Fabianowski, 2004/05/29
- Re: [Qemu-devel] Changing RTC from UTC to local time, Tim, 2004/05/29
- Re: [Qemu-devel] Changing RTC from UTC to local time, Bartosz Fabianowski, 2004/05/29
- Re: [Qemu-devel] Changing RTC from UTC to local time, John R. Hogerhuis, 2004/05/30
- Re: [Qemu-devel] Changing RTC from UTC to local time, Bartosz Fabianowski, 2004/05/30
- Re: [Qemu-devel] Changing RTC from UTC to local time, Kyle Hayes, 2004/05/30
- Re: [Qemu-devel] Changing RTC from UTC to local time, Pavel JanÃk, 2004/05/31
- Re: [Qemu-devel] Changing RTC from UTC to local time, Bartosz Fabianowski, 2004/05/31
- Re: [Qemu-devel] Changing RTC from UTC to local time, Fabrice Bellard, 2004/05/31