From: Keir Fraser Date: Tue, 29 Jan 2008 15:28:40 +0000 (+0000) Subject: xend: Obey localtime config option for HVM guests as well as PV guests. X-Git-Tag: 3.1.3-rc3~3 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7f59b649b916a27e9e87c3e6a0f11e71787b9157;p=people%2Fvhanquez%2Fxen.git xend: Obey localtime config option for HVM guests as well as PV guests. Signed-off-by: Keir Fraser xen-unstable changeset: 16932:04e24b9dcc1649e86d3e94a81489dab9c6ec82bc xen-unstable date: Tue Jan 29 15:15:51 2008 +0000 --- diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index c0e9ffaba..ac230f326 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -1047,23 +1047,13 @@ static PyObject *pyxc_domain_iomem_permission(PyObject *self, static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args) { uint32_t dom; - int32_t time_offset_seconds; - time_t calendar_time; - struct tm local_time; - struct tm utc_time; + int32_t offset; - if (!PyArg_ParseTuple(args, "i", &dom)) + if (!PyArg_ParseTuple(args, "ii", &dom, &offset)) return NULL; - calendar_time = time(NULL); - localtime_r(&calendar_time, &local_time); - gmtime_r(&calendar_time, &utc_time); - /* set up to get calendar time based on utc_time, with local dst setting */ - utc_time.tm_isdst = local_time.tm_isdst; - time_offset_seconds = (int32_t)difftime(calendar_time, mktime(&utc_time)); - - if (xc_domain_set_time_offset(self->xc_handle, dom, time_offset_seconds) != 0) - return NULL; + if (xc_domain_set_time_offset(self->xc_handle, dom, offset) != 0) + return pyxc_error_to_exception(); Py_INCREF(zero); return zero; @@ -1499,6 +1489,7 @@ static PyMethodDef pyxc_methods[] = { METH_VARARGS, "\n" "Set a domain's time offset to Dom0's localtime\n" " dom [int]: Domain whose time offset is being set.\n" + " offset [int]: Time offset from UTC in seconds.\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "domain_send_trigger", diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index c04663ed6..3210d3497 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1574,10 +1574,14 @@ class XendDomainInfo: self._configureBootloader() try: - self.image = image.create(self, self.info) - if self.info['platform'].get('localtime', 0): - xc.domain_set_time_offset(self.domid) + t = time.time() + loc = time.localtime(t) + utc = time.gmtime(t) + timeoffset = int(time.mktime(loc) - time.mktime(utc)) + self.info['platform']['rtc_timeoffset'] = timeoffset + + self.image = image.create(self, self.info) xc.domain_setcpuweight(self.domid, self.info['cpu_weight']) diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 74b829858..b9bb7e18f 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -268,6 +268,12 @@ class HVMImageHandler(ImageHandler): self.acpi = int(vmConfig['platform'].get('acpi', 0)) + def configure(self, vmConfig): + ImageHandler.configure(self, vmConfig) + rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset') + if rtc_timeoffset is not None: + xc.domain_set_time_offset(self.vm.getDomid(), rtc_timeoffset) + def buildDomain(self): store_evtchn = self.vm.getStorePort()