qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Changing RTC from UTC to local time


From: Bartosz Fabianowski
Subject: Re: [Qemu-devel] Changing RTC from UTC to local time
Date: Sun, 30 May 2004 21:32:26 +0200
User-agent: Mozilla Thunderbird 0.6 (X11/20040517)

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
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 */
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]