From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BUWAL-0000E6-OA for qemu-devel@nongnu.org; Sun, 30 May 2004 15:40:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BUWAK-0000Ca-6N for qemu-devel@nongnu.org; Sun, 30 May 2004 15:40:16 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BUWAJ-0000Bo-Tr for qemu-devel@nongnu.org; Sun, 30 May 2004 15:40:15 -0400 Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BUW9x-0002n8-3r for qemu-devel@nongnu.org; Sun, 30 May 2004 15:39:53 -0400 Received: from [81.209.184.159] (helo=dd2718.kasserver.com) by mx20.gnu.org with esmtp (Exim 4.34) id 1BUW2m-0007Yw-Ij for qemu-devel@nongnu.org; Sun, 30 May 2004 15:32:28 -0400 Message-ID: <40BA36CA.6070805@fabianowski.de> Date: Sun, 30 May 2004 21:32:26 +0200 From: Bartosz Fabianowski MIME-Version: 1.0 Subject: Re: [Qemu-devel] Changing RTC from UTC to local time References: <40B8A0B1.3040601@fabianowski.de> <200405291023.18228.kyle@silverbeach.net> <40B8DB75.5050005@fabianowski.de> <20040529231327.GC1690@sentinelchicken.org> <40B91B89.9000500@fabianowski.de> <1085892773.25895.68.camel@aragorn> In-Reply-To: <1085892773.25895.68.camel@aragorn> Content-Type: multipart/mixed; boundary="------------080801020800020801040207" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: jhoger@pobox.com, qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080801020800020801040207 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Attached is a revised patch. With this patch, the default time zone for the RTC is the local time zone of the host. If the command line option "-utc" is specified, the time zone changes to UTC. This patch applies cleanly, compiles and runs with today's QEMU CVS for me. - Bartosz --------------080801020800020801040207 Content-Type: text/plain; name="qemu-rtc.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-rtc.patch" diff -ru qemu.orig/hw/mc146818rtc.c qemu/hw/mc146818rtc.c --- qemu.orig/hw/mc146818rtc.c Sun May 30 21:17:35 2004 +++ qemu/hw/mc146818rtc.c Sun May 30 21:06:14 2004 @@ -235,7 +235,10 @@ time_t ti; ti = s->current_time; - rtc_set_date_buf(s, gmtime(&ti)); + if (rtc_utc) + rtc_set_date_buf(s, gmtime(&ti)); + else + rtc_set_date_buf(s, localtime(&ti)); if (!(s->cmos_data[RTC_REG_B] & REG_B_SET)) { rtc_copy_date(s); diff -ru qemu.orig/hw/pc.c qemu/hw/pc.c --- qemu.orig/hw/pc.c Sun May 30 21:17:35 2004 +++ qemu/hw/pc.c Sun May 30 21:06:42 2004 @@ -110,7 +110,10 @@ /* set the CMOS date */ time(&ti); - tm = gmtime(&ti); + if (rtc_utc) + tm = gmtime(&ti); + else + tm = localtime(&ti); rtc_set_date(s, tm); val = to_bcd(s, (tm->tm_year / 100) + 19); diff -ru qemu.orig/vl.c qemu/vl.c --- qemu.orig/vl.c Sun May 30 21:17:35 2004 +++ qemu/vl.c Sun May 30 21:14:20 2004 @@ -129,6 +129,7 @@ int audio_enabled = 0; int pci_enabled = 0; int prep_enabled = 0; +int rtc_utc = 0; /***********************************************************/ /* x86 ISA bus support */ @@ -1940,6 +1941,7 @@ "-m megs set virtual RAM size to megs MB [default=%d]\n" "-nographic disable graphical output and redirect serial I/Os to console\n" "-enable-audio enable audio support\n" + "-utc set the real time clock to UTC, not local time time\n" "\n" "Network options:\n" "-nics n simulate 'n' network cards [default=1]\n" @@ -2026,6 +2028,7 @@ QEMU_OPTION_no_code_copy, QEMU_OPTION_pci, QEMU_OPTION_prep, + QEMU_OPTION_utc, }; typedef struct QEMUOption { @@ -2076,6 +2079,7 @@ #ifdef TARGET_PPC { "prep", 0, QEMU_OPTION_prep }, #endif + { "utc", 0, QEMU_OPTION_utc }, { NULL }, }; @@ -2351,6 +2355,9 @@ break; case QEMU_OPTION_prep: prep_enabled = 1; + break; + case QEMU_OPTION_utc: + rtc_utc = 1; break; } } diff -ru qemu.orig/vl.h qemu/vl.h --- qemu.orig/vl.h Sun May 30 21:17:35 2004 +++ qemu/vl.h Sun May 30 21:04:55 2004 @@ -543,6 +543,7 @@ RTCState *rtc_init(int base, int irq); void rtc_set_memory(RTCState *s, int addr, int val); void rtc_set_date(RTCState *s, const struct tm *tm); +extern int rtc_utc; /* serial.c */ --------------080801020800020801040207--