ia64/xen-unstable

diff tools/ioemu/hw/mc146818rtc.c @ 10078:345464c2fd47

Allow to specify different time-of-day clock offsets for HVM guests.

There are some usage scenarios in which differing user domains want
to be using different base TOD clocks. This patch adds the ability
to specify the base TOD time difference. The patch also adds a
hook point to notify another entity when the domain changes this
offset. This might occur, for instance, on a Linux domain using
hwclock -w.

Signed-off-by: Ben Thomas <ben@virtualiron.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 17 23:43:32 2006 +0100 (2006-05-17)
parents 8e5fc5fe636c
children
line diff
     1.1 --- a/tools/ioemu/hw/mc146818rtc.c	Wed May 17 23:41:59 2006 +0100
     1.2 +++ b/tools/ioemu/hw/mc146818rtc.c	Wed May 17 23:43:32 2006 +0100
     1.3 @@ -178,10 +178,27 @@ static inline int from_bcd(RTCState *s, 
     1.4      }
     1.5  }
     1.6  
     1.7 +static void send_timeoffset_msg(time_t delta)
     1.8 +{
     1.9 +
    1.10 +/* This routine is used to inform another entity that the
    1.11 +   base time offset has changed. For instance, if you
    1.12 +   were using xenstore, you might want to write to the store
    1.13 +   at this point.  Or, you might use some other method.
    1.14 +   Whatever you might choose, here's a hook point to implement it.
    1.15 +
    1.16 +   One item of note is that this delta is in addition to
    1.17 +   any existing offset you might be already using. */
    1.18 +
    1.19 +    return;
    1.20 +}
    1.21 +
    1.22  static void rtc_set_time(RTCState *s)
    1.23  {
    1.24      struct tm *tm = &s->current_tm;
    1.25 -
    1.26 +    time_t before, after;
    1.27 +    
    1.28 +    before = mktime(tm);
    1.29      tm->tm_sec = from_bcd(s, s->cmos_data[RTC_SECONDS]);
    1.30      tm->tm_min = from_bcd(s, s->cmos_data[RTC_MINUTES]);
    1.31      tm->tm_hour = from_bcd(s, s->cmos_data[RTC_HOURS] & 0x7f);
    1.32 @@ -193,6 +210,12 @@ static void rtc_set_time(RTCState *s)
    1.33      tm->tm_mday = from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]);
    1.34      tm->tm_mon = from_bcd(s, s->cmos_data[RTC_MONTH]) - 1;
    1.35      tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100;
    1.36 +
    1.37 +    /* Compute, and send, the additional time delta
    1.38 +       We could compute the total time delta, but this is
    1.39 +       sufficient, and simple. */
    1.40 +    after = mktime(tm);
    1.41 +    send_timeoffset_msg(after-before);
    1.42  }
    1.43  
    1.44  static void rtc_copy_date(RTCState *s)