Ross S. W. Walker
2008-Mar-31 17:35 UTC
[Xen-devel] [PATCH] Obey localtime config option for HVM guests as well as PV guests (changeset 16932)
First my apologies if this doesn''t fit the submission guidelines. I currently don''t have access to mecurial so it was done by hand off-line. Here is my copy of the updated changeset 16932 from 3.2-testing. Basically the same as the original 16932 changeset, except down where it calculates the utc_timeoffset it uses the builtin ''timezone'' and ''altzone'' variables from the Python ''time'' module, testing whether daylight savings time is in affect and using ''altzone'' if it is or ''timezone'' if it isn''t. These are specified as seconds west of UTC, so I had to negate them to fit. Ross S. W. Walker --- a/tools/python/xen/lowlevel/xc/xc.c Tue Jan 29 15:24:04 2008 +0000 +++ b/tools/python/xen/lowlevel/xc/xc.c Tue Jan 29 15:24:34 2008 +0000 @@ -1154,23 +1154,13 @@ static PyObject *pyxc_domain_set_time_of 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; - - if (!PyArg_ParseTuple(args, "i", &dom)) - 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; + int32_t offset; + + if (!PyArg_ParseTuple(args, "ii", &dom, &offset)) + return NULL; + + if (xc_domain_set_time_offset(self->xc_handle, dom, offset) != 0) + return pyxc_error_to_exception(); Py_INCREF(zero); return zero; @@ -1619,6 +1609,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", --- a/tools/python/xen/xend/XendDomainInfo.py Tue Jan 29 15:24:04 2008 +0000 +++ b/tools/python/xen/xend/XendDomainInfo.py Tue Jan 29 15:24:34 2008 +0000 @@ -1700,10 +1700,13 @@ class XendDomainInfo: self._configureBootloader() try: + if self.info[''platform''].get(''localtime'', 0): + if time.localtime(time.time())[8]: + self.info[''platform''][''rtc_timeoffset''] = -time.altzone + else: + self.info[''platform''][''rtc_timeoffset''] = -time.timezone + self.image = image.create(self, self.info) - - if self.info[''platform''].get(''localtime'', 0): - xc.domain_set_time_offset(self.domid) xc.domain_setcpuweight(self.domid, \ self.info[''vcpus_params''][''weight'']) --- a/tools/python/xen/xend/image.py Tue Jan 29 15:24:04 2008 +0000 +++ b/tools/python/xen/xend/image.py Tue Jan 29 15:24:34 2008 +0000 @@ -342,6 +342,12 @@ class LinuxImageHandler(ImageHandler): flags = 0 vhpt = 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() console_evtchn = self.vm.getConsolePort() ______________________________________________________________________ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2008-Apr-01 07:09 UTC
Re: [Xen-devel] [PATCH] Obey localtime config option for HVM guests as well as PV guests (changeset 16932)
On 31/3/08 18:35, "Ross S. W. Walker" <rwalker@medallion.com> wrote:> > First my apologies if this doesn''t fit the submission > guidelines. I currently don''t have access to mecurial so > it was done by hand off-line. > > Here is my copy of the updated changeset 16932 from 3.2-testing.I already applied your patch to the 3.1 and 3.2 branches. They may not be in the main trees yet but only in the staging repositories: http://xenbits.xensource.com/staging/xen-3.1-testing.hg http://xenbits.xensource.com/staging/xen-3.2-testing.hg Thanks, Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ross S. W. Walker
2008-Apr-01 14:20 UTC
RE: [Xen-devel] [PATCH] Obey localtime config option for HVM guests as well as PV guests (changeset 16932)
Keir Fraser wrote:> On 31/3/08 18:35, "Ross S. W. Walker" <rwalker@medallion.com> wrote: > > > > First my apologies if this doesn''t fit the submission > > guidelines. I currently don''t have access to mecurial so > > it was done by hand off-line. > > > > Here is my copy of the updated changeset 16932 from 3.2-testing. > > I already applied your patch to the 3.1 and 3.2 branches. They may not be in > the main trees yet but only in the staging repositories: > http://xenbits.xensource.com/staging/xen-3.1-testing.hg > http://xenbits.xensource.com/staging/xen-3.2-testing.hgThanks Keir, I was anxious to get it in there before 3.2.1 is released. Keep up the good work! -Ross ______________________________________________________________________ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel