debuggers.hg

changeset 16970:04e24b9dcc16

xend: Obey localtime config option for HVM guests as well as PV guests.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 29 15:15:51 2008 +0000 (2008-01-29)
parents 98c2665056ea
children 233f40973e1d
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Jan 29 13:46:16 2008 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Jan 29 15:15:51 2008 +0000
     1.3 @@ -1155,23 +1155,13 @@ static PyObject *pyxc_domain_iomem_permi
     1.4  static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args)
     1.5  {
     1.6      uint32_t dom;
     1.7 -    int32_t time_offset_seconds;
     1.8 -    time_t calendar_time;
     1.9 -    struct tm local_time;
    1.10 -    struct tm utc_time;
    1.11 +    int32_t offset;
    1.12  
    1.13 -    if (!PyArg_ParseTuple(args, "i", &dom))
    1.14 +    if (!PyArg_ParseTuple(args, "ii", &dom, &offset))
    1.15          return NULL;
    1.16  
    1.17 -    calendar_time = time(NULL);
    1.18 -    localtime_r(&calendar_time, &local_time);
    1.19 -    gmtime_r(&calendar_time, &utc_time);
    1.20 -    /* set up to get calendar time based on utc_time, with local dst setting */
    1.21 -    utc_time.tm_isdst = local_time.tm_isdst;
    1.22 -    time_offset_seconds = (int32_t)difftime(calendar_time, mktime(&utc_time));
    1.23 -
    1.24 -    if (xc_domain_set_time_offset(self->xc_handle, dom, time_offset_seconds) != 0)
    1.25 -        return NULL;
    1.26 +    if (xc_domain_set_time_offset(self->xc_handle, dom, offset) != 0)
    1.27 +        return pyxc_error_to_exception();
    1.28  
    1.29      Py_INCREF(zero);
    1.30      return zero;
    1.31 @@ -1620,6 +1610,7 @@ static PyMethodDef pyxc_methods[] = {
    1.32        METH_VARARGS, "\n"
    1.33        "Set a domain's time offset to Dom0's localtime\n"
    1.34        " dom        [int]: Domain whose time offset is being set.\n"
    1.35 +      " offset     [int]: Time offset from UTC in seconds.\n"
    1.36        "Returns: [int] 0 on success; -1 on error.\n" },
    1.37  
    1.38      { "domain_send_trigger",
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 29 13:46:16 2008 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jan 29 15:15:51 2008 +0000
     2.3 @@ -1733,11 +1733,15 @@ class XendDomainInfo:
     2.4          self._configureBootloader()
     2.5  
     2.6          try:
     2.7 +            if self.info['platform'].get('localtime', 0):
     2.8 +                t = time.time()
     2.9 +                loc = time.localtime(t)
    2.10 +                utc = time.gmtime(t)
    2.11 +                timeoffset = int(time.mktime(loc) - time.mktime(utc))
    2.12 +                self.info['platform']['rtc_timeoffset'] = timeoffset
    2.13 +
    2.14              self.image = image.create(self, self.info)
    2.15  
    2.16 -            if self.info['platform'].get('localtime', 0):
    2.17 -                xc.domain_set_time_offset(self.domid)
    2.18 -
    2.19              xc.domain_setcpuweight(self.domid, \
    2.20                                     self.info['vcpus_params']['weight'])
    2.21  
     3.1 --- a/tools/python/xen/xend/image.py	Tue Jan 29 13:46:16 2008 +0000
     3.2 +++ b/tools/python/xen/xend/image.py	Tue Jan 29 15:15:51 2008 +0000
     3.3 @@ -346,6 +346,12 @@ class LinuxImageHandler(ImageHandler):
     3.4      flags = 0
     3.5      vhpt = 0
     3.6  
     3.7 +    def configure(self, vmConfig):
     3.8 +        ImageHandler.configure(self, vmConfig)
     3.9 +        rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
    3.10 +        if rtc_timeoffset is not None:
    3.11 +            xc.domain_set_time_offset(self.vm.getDomid(), rtc_timeoffset)
    3.12 +
    3.13      def buildDomain(self):
    3.14          store_evtchn = self.vm.getStorePort()
    3.15          console_evtchn = self.vm.getConsolePort()