aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-09-15 13:36:04 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-05 09:32:45 -0500
commit6875204c782e7c9aa5c28f96b2583fd31c50468f (patch)
tree108600320ec5820c8f13e8a1e5c24954132eb293 /vl.c
parent1ed2fc1fa35fadc0d6f5d9b55b9f84ccaa87a036 (diff)
Enable host-clock-based RTC
Switch RTC emulations to the new host_clock instead of vm_clock by default. This has the advantage that the emulated RTC will follow automatically the host time while it might be tuned via NTP. vm_clock can still be selected by passing '-rtc clock=vm' on the command line. Note that some RTC emulations (at least M48T59) already use the host time unconditionally while others (namely MC146818) do not. This patch introduces the required infrastructure for selecting the base clock but only converts MC146818 for now. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/vl.c b/vl.c
index 31f3ad2500..dd2de980e8 100644
--- a/vl.c
+++ b/vl.c
@@ -196,6 +196,7 @@ int vm_running;
int autostart;
static int rtc_utc = 1;
static int rtc_date_offset = -1; /* -1 means no change */
+QEMUClock *rtc_clock;
int vga_interface_type = VGA_CIRRUS;
#ifdef TARGET_SPARC
int graphic_width = 1024;
@@ -1055,6 +1056,8 @@ static void init_clocks(void)
rt_clock = qemu_new_clock(QEMU_CLOCK_REALTIME);
vm_clock = qemu_new_clock(QEMU_CLOCK_VIRTUAL);
host_clock = qemu_new_clock(QEMU_CLOCK_HOST);
+
+ rtc_clock = host_clock;
}
/* save a timer */
@@ -1635,6 +1638,17 @@ static void configure_rtc(QemuOpts *opts)
configure_rtc_date_offset(value, 0);
}
}
+ value = qemu_opt_get(opts, "clock");
+ if (value) {
+ if (!strcmp(value, "host")) {
+ rtc_clock = host_clock;
+ } else if (!strcmp(value, "vm")) {
+ rtc_clock = vm_clock;
+ } else {
+ fprintf(stderr, "qemu: invalid option value '%s'\n", value);
+ exit(1);
+ }
+ }
#ifdef CONFIG_TARGET_I386
value = qemu_opt_get(opts, "driftfix");
if (value) {
@@ -4754,6 +4768,8 @@ int main(int argc, char **argv, char **envp)
CPUState *env;
int show_vnc_port = 0;
+ init_clocks();
+
qemu_errors_to_file(stderr);
qemu_cache_utils_init(envp);
@@ -5619,7 +5635,6 @@ int main(int argc, char **argv, char **envp)
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
- init_clocks();
if (init_timer_alarm() < 0) {
fprintf(stderr, "could not initialize alarm timer\n");
exit(1);