ia64/xen-unstable
changeset 12099:acb85833be66
[XEND][XM] Fix bug in XendDomainInfo.recreate introduced by refactoring.
* Replaced autostart and autostop with more descriptive on_xend_start
and on_xend_stop for the configuration.
Signed-off-by: Alastair Tse <atse@xensource.com>
* Replaced autostart and autostop with more descriptive on_xend_start
and on_xend_stop for the configuration.
Signed-off-by: Alastair Tse <atse@xensource.com>
author | Alastair Tse <atse@xensource.com> |
---|---|
date | Thu Oct 05 18:24:18 2006 +0100 (2006-10-05) |
parents | d1f6aa51621f |
children | 8e5e7399e9b5 |
files | tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py |
line diff
1.1 --- a/tools/python/xen/xend/XendConfig.py Thu Oct 05 18:22:13 2006 +0100 1.2 +++ b/tools/python/xen/xend/XendConfig.py Thu Oct 05 18:24:18 2006 +0100 1.3 @@ -124,12 +124,11 @@ XENAPI_UNSUPPORTED_IN_LEGACY_CFG = [ 1.4 1.5 # All parameters of VMs that may be configured on-the-fly, or at start-up. 1.6 VM_CONFIG_ENTRIES = [ 1.7 - ('autostart', int), 1.8 - ('autostop', int), 1.9 ('name', str), 1.10 ('on_crash', str), 1.11 ('on_poweroff', str), 1.12 ('on_reboot', str), 1.13 + ('on_xend_start', str), 1.14 ('on_xend_stop', str), 1.15 ] 1.16 1.17 @@ -216,9 +215,8 @@ DEFAULT_CONFIGURATION = ( 1.18 ('device', lambda info: {}), 1.19 ('image', lambda info: None), 1.20 ('security', lambda info: []), 1.21 - ('autostart', lambda info: 0), 1.22 - ('autostop', lambda info: 0), 1.23 - ('on_xend_stop', lambda info: 'shutdown'), 1.24 + ('on_xend_start', lambda info: 'ignore'), 1.25 + ('on_xend_stop', lambda info: 'ignore'), 1.26 1.27 ('cpus', lambda info: []), 1.28 ('cpu_weight', lambda info: 1.0), 1.29 @@ -469,7 +467,7 @@ class XendConfig(dict): 1.30 dev_info = {} 1.31 for opt, val in config[1:]: 1.32 dev_info[opt] = val 1.33 - 1.34 + log.debug("XendConfig: reading device: %s" % dev_info) 1.35 # create uuid if it doesn't 1.36 dev_uuid = dev_info.get('uuid', uuid.createString()) 1.37 dev_info['uuid'] = dev_uuid 1.38 @@ -654,9 +652,8 @@ class XendConfig(dict): 1.39 sxpr.append(['up_time', str(uptime)]) 1.40 sxpr.append(['start_time', str(self['start_time'])]) 1.41 1.42 - sxpr.append(['autostart', self.get('autostart', 0)]) 1.43 - sxpr.append(['autostop', self.get('autostop', 0)]) 1.44 - sxpr.append(['on_xend_stop', self.get('on_xend_stop', 'shutdown')]) 1.45 + sxpr.append(['on_xend_start', self.get('on_xend_start', 'ignore')]) 1.46 + sxpr.append(['on_xend_stop', self.get('on_xend_stop', 'ignore')]) 1.47 1.48 sxpr.append(['status', domain.state]) 1.49 1.50 @@ -729,6 +726,8 @@ class XendConfig(dict): 1.51 raise XendConfigError("XendConfig: device_add requires some " 1.52 "config.") 1.53 1.54 + log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) 1.55 + 1.56 if cfg_sxp: 1.57 config = sxp.child0(cfg_sxp) 1.58 dev_type = sxp.name(config) 1.59 @@ -738,7 +737,6 @@ class XendConfig(dict): 1.60 for opt, val in config[1:]: 1.61 dev_info[opt] = val 1.62 except ValueError: 1.63 - log.debug('XendConfig.device_add: %s' % config) 1.64 pass # SXP has no options for this device 1.65 1.66 # create uuid if it doesn't exist
2.1 --- a/tools/python/xen/xend/XendDomain.py Thu Oct 05 18:22:13 2006 +0100 2.2 +++ b/tools/python/xen/xend/XendDomain.py Thu Oct 05 18:24:18 2006 +0100 2.3 @@ -523,8 +523,7 @@ class XendDomain: 2.4 continue 2.5 2.6 if dom.state == XendDomainInfo.DOM_STATE_RUNNING: 2.7 - shouldShutdown = dom.info.get('autostop', 0) 2.8 - shutdownAction = dom.info.get('on_xend_stop', 'shutdown') 2.9 + shutdownAction = dom.info.get('on_xend_stop', 'ignore') 2.10 if shouldShutdown and shutdownAction == 'shutdown': 2.11 log.debug('Shutting down domain: %s' % dom.getName()) 2.12 dom.shutdown("poweroff")
3.1 --- a/tools/python/xen/xend/XendDomainInfo.py Thu Oct 05 18:22:13 2006 +0100 3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Oct 05 18:24:18 2006 +0100 3.3 @@ -102,8 +102,7 @@ VM_STORE_ENTRIES = [ 3.4 ('shadow_memory', int), 3.5 ('maxmem', int), 3.6 ('start_time', float), 3.7 - ('autostart', int), 3.8 - ('autostop', int), 3.9 + ('on_xend_start', str), 3.10 ('on_xend_stop', str), 3.11 ] 3.12 3.13 @@ -194,23 +193,28 @@ def recreate(info, priv): 3.14 # entry disappears (eg. xenstore-rm /) 3.15 # 3.16 if domid != 0: 3.17 - vmpath = xstransact.Read(dompath, "vm") 3.18 - if not vmpath: 3.19 - log.warn('/dom/%d/vm is missing. recreate is confused, trying ' 3.20 - 'our best to recover' % domid) 3.21 - needs_reinitialising = True 3.22 - 3.23 - uuid2_str = xstransact.Read(vmpath, "uuid") 3.24 - if not uuid2_str: 3.25 - log.warn('%s/uuid/ is missing. recreate is confused, trying ' 3.26 - 'our best to recover' % vmpath) 3.27 - needs_reinitialising = True 3.28 + try: 3.29 + vmpath = xstransact.Read(dompath, "vm") 3.30 + if not vmpath: 3.31 + log.warn('/dom/%d/vm is missing. recreate is confused, ' 3.32 + 'trying our best to recover' % domid) 3.33 + needs_reinitialising = True 3.34 + raise XendError('reinit') 3.35 + 3.36 + uuid2_str = xstransact.Read(vmpath, "uuid") 3.37 + if not uuid2_str: 3.38 + log.warn('%s/uuid/ is missing. recreate is confused, ' 3.39 + 'trying our best to recover' % vmpath) 3.40 + needs_reinitialising = True 3.41 + raise XendError('reinit') 3.42 3.43 - uuid2 = uuid.fromString(uuid2_str) 3.44 - if uuid1 != uuid2: 3.45 - log.warn('UUID in /vm does not match the UUID in /dom/%d.' 3.46 - 'Trying out best to recover' % domid) 3.47 - needs_reinitialising = True 3.48 + uuid2 = uuid.fromString(uuid2_str) 3.49 + if uuid1 != uuid2: 3.50 + log.warn('UUID in /vm does not match the UUID in /dom/%d.' 3.51 + 'Trying out best to recover' % domid) 3.52 + needs_reinitialising = True 3.53 + except XendError: 3.54 + pass # our best shot at 'goto' in python :) 3.55 3.56 vm = XendDomainInfo(xeninfo, domid, dompath, augment = True, priv = priv) 3.57 3.58 @@ -263,7 +267,6 @@ def createDormant(xeninfo): 3.59 3.60 # Remove domid and uuid do not make sense for non-running domains. 3.61 xeninfo.pop('domid', None) 3.62 - xeninfo.pop('uuid', None) 3.63 vm = XendDomainInfo(XendConfig(cfg = xeninfo)) 3.64 return vm 3.65 3.66 @@ -506,10 +509,11 @@ class XendDomainInfo: 3.67 @param dev_config: device configuration 3.68 @type dev_config: dictionary (parsed config) 3.69 """ 3.70 + log.debug("XendDomainInfo.device_create: %s" % dev_config) 3.71 dev_type = sxp.name(dev_config) 3.72 devid = self._createDevice(dev_type, dev_config) 3.73 + self.info.device_add(dev_type, cfg_sxp = dev_config) 3.74 self._waitForDevice(dev_type, devid) 3.75 - self.info.device_add(dev_type, cfg_sxp = dev_config) 3.76 return self.getDeviceController(dev_type).sxpr(devid) 3.77 3.78 def device_configure(self, dev_config, devid): 3.79 @@ -622,7 +626,7 @@ class XendDomainInfo: 3.80 3.81 if not self.info['device'] and devices is not None: 3.82 for device in devices: 3.83 - self.info.device_add(device[0], cfg_sxp = device[1]) 3.84 + self.info.device_add(device[0], cfg_sxp = device) 3.85 3.86 # 3.87 # Function to update xenstore /vm/*
4.1 --- a/tools/python/xen/xm/create.py Thu Oct 05 18:22:13 2006 +0100 4.2 +++ b/tools/python/xen/xm/create.py Thu Oct 05 18:24:18 2006 +0100 4.3 @@ -439,17 +439,14 @@ gopts.var('uuid', val='', 4.4 addresses for virtual network interfaces. This must be a unique 4.5 value across the entire cluster.""") 4.6 4.7 -gopts.var('autostart', val='no|yes', 4.8 - fn=set_bool, default=0, 4.9 - use="Should the start VM automatically when Xend starts.") 4.10 +gopts.var('on_xend_start', val='ignore|start', 4.11 + fn=set_value, default='ignore', 4.12 + use='Action to perform when xend starts') 4.13 4.14 -gopts.var('autostop', val='no|yes', 4.15 - fn=set_bool, default=0, 4.16 - use="Should stop VM automatically when Xend stops.") 4.17 - 4.18 -gopts.var('on_xend_stop', val='shtudown|suspend', 4.19 - fn=set_value, default="shutdown", 4.20 - use="""Behaviour when Xend stops and autostop is on: 4.21 +gopts.var('on_xend_stop', val='continue|shutdown|suspend', 4.22 + fn=set_value, default="ignore", 4.23 + use="""Behaviour when Xend stops: 4.24 + - ignore: Domain continues to run; 4.25 - shutdown: Domain is shutdown; 4.26 - suspend: Domain is suspended; 4.27 """) 4.28 @@ -685,7 +682,7 @@ def make_config(vals): 4.29 map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory', 4.30 'restart', 'on_poweroff', 4.31 'on_reboot', 'on_crash', 'vcpus', 'features', 4.32 - 'autostart', 'autostop', 'on_xend_stop']) 4.33 + 'on_xend_start', 'on_xend_stop']) 4.34 4.35 if vals.uuid is not None: 4.36 config.append(['uuid', vals.uuid])