# HG changeset patch # Parent f2543f449a49b8979becbf6888e009973427089a hvm: correct RTC time offset update error due to tm->tm_year mktime requires input year in normal date format, i.e. 1980. So it is necessary to change tm->tm_year to tm->tm_year+1900. Otherwise, the calculation result of mktime is incorrect. Signed-off-by: Annie Li diff -r f2543f449a49 xen/arch/x86/hvm/rtc.c --- a/xen/arch/x86/hvm/rtc.c Mon Feb 13 17:57:47 2012 +0000 +++ b/xen/arch/x86/hvm/rtc.c Mon Feb 20 14:39:00 2012 +0800 @@ -165,7 +165,7 @@ static void rtc_set_time(RTCState *s) ASSERT(spin_is_locked(&s->lock)); - before = mktime(tm->tm_year, tm->tm_mon + 1, tm->tm_mday, + before = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); tm->tm_sec = from_bcd(s, s->hw.cmos_data[RTC_SECONDS]); @@ -179,7 +179,7 @@ static void rtc_set_time(RTCState *s) 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 + 1, tm->tm_mday, + after = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); /* We use the guest's setting of the RTC to define the local-time