ia64/xen-unstable

changeset 19487:5d701be7c37b

xend: fix rtc_timeoffset when localtime=1

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@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 01 11:47:25 2009 +0100 (2009-04-01)
parents 5759a5766cca
children 79f734040a83
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/image.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Apr 01 11:46:31 2009 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Apr 01 11:47:25 2009 +0100
     1.3 @@ -1605,9 +1605,6 @@ class XendDomainInfo:
     1.4          # convert two lists into a python dictionary
     1.5          vm_details = dict(zip(cfg_vm, vm_details))
     1.6  
     1.7 -        if vm_details['rtc/timeoffset'] == None:
     1.8 -            vm_details['rtc/timeoffset'] = "0"
     1.9 -
    1.10          for arg, val in vm_details.items():
    1.11              if arg in XendConfig.LEGACY_CFG_TO_XENAPI_CFG:
    1.12                  xapiarg = XendConfig.LEGACY_CFG_TO_XENAPI_CFG[arg]
    1.13 @@ -1629,10 +1626,10 @@ class XendDomainInfo:
    1.14              self.info.update_with_image_sxp(sxp.from_string(image_sxp))
    1.15              changed = True
    1.16  
    1.17 -        # Check if the rtc offset has changes
    1.18 -        if vm_details.get("rtc/timeoffset", "0") != self.info["platform"].get("rtc_timeoffset", "0"):
    1.19 -            self.info["platform"]["rtc_timeoffset"] = vm_details.get("rtc/timeoffset", 0)
    1.20 -            changed = True
    1.21 +        # Update the rtc_timeoffset to be preserved across reboot.
    1.22 +        # NB. No need to update xenstore domain section.
    1.23 +        val = int(vm_details.get("rtc/timeoffset", 0))
    1.24 +        self.info["platform"]["rtc_timeoffset"] = val
    1.25   
    1.26          if changed:
    1.27              # Update the domain section of the store, as this contains some
    1.28 @@ -2440,12 +2437,6 @@ class XendDomainInfo:
    1.29          self._configureBootloader()
    1.30  
    1.31          try:
    1.32 -            if self.info['platform'].get('localtime', 0):
    1.33 -                if time.localtime(time.time())[8]:
    1.34 -                    self.info['platform']['rtc_timeoffset'] = -time.altzone
    1.35 -                else:
    1.36 -                    self.info['platform']['rtc_timeoffset'] = -time.timezone
    1.37 -
    1.38              self.image = image.create(self, self.info)
    1.39  
    1.40              # repin domain vcpus if a restricted cpus list is provided
     2.1 --- a/tools/python/xen/xend/image.py	Wed Apr 01 11:46:31 2009 +0100
     2.2 +++ b/tools/python/xen/xend/image.py	Wed Apr 01 11:47:25 2009 +0100
     2.3 @@ -119,9 +119,14 @@ class ImageHandler:
     2.4          self.vncconsole = int(vmConfig['platform'].get('vncconsole', 0))
     2.5          self.dmargs = self.parseDeviceModelArgs(vmConfig)
     2.6          self.pid = None
     2.7 -        rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
     2.8 -        if rtc_timeoffset is not None:
     2.9 -            xc.domain_set_time_offset(self.vm.getDomid(), int(rtc_timeoffset))
    2.10 +        rtc_timeoffset = int(vmConfig['platform'].get('rtc_timeoffset', 0))
    2.11 +        if vmConfig['platform'].get('localtime', 0):
    2.12 +            if time.localtime(time.time())[8]:
    2.13 +                rtc_timeoffset -= time.altzone
    2.14 +            else:
    2.15 +                rtc_timeoffset -= time.timezone
    2.16 +        if rtc_timeoffset != 0:
    2.17 +            xc.domain_set_time_offset(self.vm.getDomid(), rtc_timeoffset)
    2.18  
    2.19          self.cpuid = None
    2.20          self.cpuid_check = None
     3.1 --- a/tools/python/xen/xm/create.py	Wed Apr 01 11:46:31 2009 +0100
     3.2 +++ b/tools/python/xen/xm/create.py	Wed Apr 01 11:47:25 2009 +0100
     3.3 @@ -204,7 +204,7 @@ gopts.var('cpus', val='CPUS',
     3.4            use="CPUS to run the domain on.")
     3.5  
     3.6  gopts.var('rtc_timeoffset', val='RTC_TIMEOFFSET',
     3.7 -          fn=set_value, default="0",
     3.8 +          fn=set_int, default=0,
     3.9            use="Set RTC offset.")
    3.10  
    3.11  gopts.var('pae', val='PAE',