From: Bartosz Fabianowski <bartosz@fabianowski.de>
To: jhoger@pobox.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Changing RTC from UTC to local time
Date: Sun, 30 May 2004 21:32:26 +0200 [thread overview]
Message-ID: <40BA36CA.6070805@fabianowski.de> (raw)
In-Reply-To: <1085892773.25895.68.camel@aragorn>
[-- Attachment #1: Type: text/plain, Size: 284 bytes --]
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
[-- Attachment #2: qemu-rtc.patch --]
[-- Type: text/plain, Size: 2495 bytes --]
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 */
next prev parent reply other threads:[~2004-05-30 19:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40BA36CA.6070805@fabianowski.de \
--to=bartosz@fabianowski.de \
--cc=jhoger@pobox.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.