diff options
author | Christian Limpach <Christian.Limpach@xensource.com> | 2007-04-03 13:22:37 +0100 |
---|---|---|
committer | Christian Limpach <Christian.Limpach@xensource.com> | 2007-04-03 13:22:37 +0100 |
commit | 2bdbd3e1939805676f7b025a58d23cea942fe042 (patch) | |
tree | 4f4b89a44dcfb432dc4313f6fe1692f51ad50822 /xen/arch/x86/hvm/rtc.c | |
parent | 9423a78d7fb9a3f9cab740a88e6ec74b6275e76b (diff) | |
download | xen-2bdbd3e1939805676f7b025a58d23cea942fe042.tar.gz xen-2bdbd3e1939805676f7b025a58d23cea942fe042.tar.bz2 xen-2bdbd3e1939805676f7b025a58d23cea942fe042.zip |
[hvm] Keep track of time offset between domain time and dom0 time.
On each rtc time update from the hvm domain, we send an ioreq request
to qemu which then updates the time offset xenstore entry. The time
offset is preserved across reboot and can be set on domain creation
by setting the rtc_timeoffset variable in a config file.
From: Andrei Petrov <andrei.petrov@xensource.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
Diffstat (limited to 'xen/arch/x86/hvm/rtc.c')
-rw-r--r-- | xen/arch/x86/hvm/rtc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c index 036eba7bfe..1b18dca204 100644 --- a/xen/arch/x86/hvm/rtc.c +++ b/xen/arch/x86/hvm/rtc.c @@ -157,6 +157,10 @@ static inline int from_bcd(RTCState *s, int a) static void rtc_set_time(RTCState *s) { struct tm *tm = &s->current_tm; + unsigned long before, after; /* XXX s_time_t */ + + before = mktime(tm->tm_year, tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); tm->tm_sec = from_bcd(s, s->hw.cmos_data[RTC_SECONDS]); tm->tm_min = from_bcd(s, s->hw.cmos_data[RTC_MINUTES]); @@ -168,6 +172,10 @@ static void rtc_set_time(RTCState *s) tm->tm_mday = from_bcd(s, s->hw.cmos_data[RTC_DAY_OF_MONTH]); tm->tm_mon = from_bcd(s, s->hw.cmos_data[RTC_MONTH]) - 1; tm->tm_year = from_bcd(s, s->hw.cmos_data[RTC_YEAR]) + 100; + + after = mktime(tm->tm_year, tm->tm_mon, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + send_timeoffset_req(after - before); } static void rtc_copy_date(RTCState *s) |