WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xend: fix rtc_timeoffset when localtime=1

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xend: fix rtc_timeoffset when localtime=1
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Wed, 1 Apr 2009 16:53:33 +0900
Delivery-date: Wed, 01 Apr 2009 00:54:12 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The rtc_timeoffset parameter in VM config is ignored when localtime=1.
Also it is not preserved across reboot.

NOTE:
This patch changes the meaning of the xenstore /vm/<uuid>/rtc/timeoffset
from utc offset to local offset. (it's OK for the ioemu)

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r f6fd1c2e4da6 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Mar 31 18:37:58 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Apr 01 15:28:12 2009 +0900
@@ -1605,9 +1605,6 @@ class XendDomainInfo:
         # convert two lists into a python dictionary
         vm_details = dict(zip(cfg_vm, vm_details))
 
-        if vm_details['rtc/timeoffset'] == None:
-            vm_details['rtc/timeoffset'] = "0"
-
         for arg, val in vm_details.items():
             if arg in XendConfig.LEGACY_CFG_TO_XENAPI_CFG:
                 xapiarg = XendConfig.LEGACY_CFG_TO_XENAPI_CFG[arg]
@@ -1629,10 +1626,10 @@ class XendDomainInfo:
             self.info.update_with_image_sxp(sxp.from_string(image_sxp))
             changed = True
 
-        # Check if the rtc offset has changes
-        if vm_details.get("rtc/timeoffset", "0") != 
self.info["platform"].get("rtc_timeoffset", "0"):
-            self.info["platform"]["rtc_timeoffset"] = 
vm_details.get("rtc/timeoffset", 0)
-            changed = True
+        # Update the rtc_timeoffset to be preserved across reboot.
+        # NB. No need to update xenstore domain section.
+        val = int(vm_details.get("rtc/timeoffset", 0))
+        self.info["platform"]["rtc_timeoffset"] = val
  
         if changed:
             # Update the domain section of the store, as this contains some
@@ -2439,12 +2436,6 @@ 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)
 
             # repin domain vcpus if a restricted cpus list is provided
diff -r f6fd1c2e4da6 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Tue Mar 31 18:37:58 2009 +0100
+++ b/tools/python/xen/xend/image.py    Wed Apr 01 15:28:12 2009 +0900
@@ -119,9 +119,14 @@ class ImageHandler:
         self.vncconsole = int(vmConfig['platform'].get('vncconsole', 0))
         self.dmargs = self.parseDeviceModelArgs(vmConfig)
         self.pid = None
-        rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
-        if rtc_timeoffset is not None:
-            xc.domain_set_time_offset(self.vm.getDomid(), int(rtc_timeoffset))
+        rtc_timeoffset = int(vmConfig['platform'].get('rtc_timeoffset', 0))
+        if vmConfig['platform'].get('localtime', 0):
+            if time.localtime(time.time())[8]:
+                rtc_timeoffset -= time.altzone
+            else:
+                rtc_timeoffset -= time.timezone
+        if rtc_timeoffset != 0:
+            xc.domain_set_time_offset(self.vm.getDomid(), rtc_timeoffset)
 
         self.cpuid = None
         self.cpuid_check = None
diff -r f6fd1c2e4da6 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue Mar 31 18:37:58 2009 +0100
+++ b/tools/python/xen/xm/create.py     Wed Apr 01 15:28:12 2009 +0900
@@ -204,7 +204,7 @@ gopts.var('cpus', val='CPUS',
           use="CPUS to run the domain on.")
 
 gopts.var('rtc_timeoffset', val='RTC_TIMEOFFSET',
-          fn=set_value, default="0",
+          fn=set_int, default=0,
           use="Set RTC offset.")
 
 gopts.var('pae', val='PAE',
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel