From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BU50D-0005hq-Gj for qemu-devel@nongnu.org; Sat, 29 May 2004 10:40:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BU50B-0005hc-52 for qemu-devel@nongnu.org; Sat, 29 May 2004 10:40:01 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BU50B-0005hS-1n for qemu-devel@nongnu.org; Sat, 29 May 2004 10:39:59 -0400 Received: from [81.209.184.159] (helo=dd2718.kasserver.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BU500-0004vk-MN for qemu-devel@nongnu.org; Sat, 29 May 2004 10:39:48 -0400 Received: from [192.168.0.7] (dsl-082-082-145-164.arcor-ip.net [82.82.145.164]) by dd2718.kasserver.com (Postfix) with ESMTP id 9DB33250A9 for ; Sat, 29 May 2004 16:38:12 +0200 (CEST) Message-ID: <40B8A0B1.3040601@fabianowski.de> Date: Sat, 29 May 2004 16:39:45 +0200 From: Bartosz Fabianowski MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020203000103010801020900" Subject: [Qemu-devel] Changing RTC from UTC to local time Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020203000103010801020900 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 --------------020203000103010801020900 Content-Type: text/plain; name="local_time_patch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="local_time_patch.diff" 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); --------------020203000103010801020900--