[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [XEND][XM] Fix bug in XendDomainInfo.recreate introduced by refactoring.
# HG changeset patch # User Alastair Tse <atse@xxxxxxxxxxxxx> # Node ID acb85833be66180659fd633253aa72e10ebddd12 # Parent d1f6aa51621f27168816904a6c97b46d2012d5aa [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@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendConfig.py | 18 +++++------- tools/python/xen/xend/XendDomain.py | 3 -- tools/python/xen/xend/XendDomainInfo.py | 48 +++++++++++++++++--------------- tools/python/xen/xm/create.py | 21 ++++++-------- 4 files changed, 44 insertions(+), 46 deletions(-) diff -r d1f6aa51621f -r acb85833be66 tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Thu Oct 05 18:22:13 2006 +0100 +++ b/tools/python/xen/xend/XendConfig.py Thu Oct 05 18:24:18 2006 +0100 @@ -124,12 +124,11 @@ XENAPI_UNSUPPORTED_IN_LEGACY_CFG = [ # All parameters of VMs that may be configured on-the-fly, or at start-up. VM_CONFIG_ENTRIES = [ - ('autostart', int), - ('autostop', int), ('name', str), ('on_crash', str), ('on_poweroff', str), ('on_reboot', str), + ('on_xend_start', str), ('on_xend_stop', str), ] @@ -216,9 +215,8 @@ DEFAULT_CONFIGURATION = ( ('device', lambda info: {}), ('image', lambda info: None), ('security', lambda info: []), - ('autostart', lambda info: 0), - ('autostop', lambda info: 0), - ('on_xend_stop', lambda info: 'shutdown'), + ('on_xend_start', lambda info: 'ignore'), + ('on_xend_stop', lambda info: 'ignore'), ('cpus', lambda info: []), ('cpu_weight', lambda info: 1.0), @@ -469,7 +467,7 @@ class XendConfig(dict): dev_info = {} for opt, val in config[1:]: dev_info[opt] = val - + log.debug("XendConfig: reading device: %s" % dev_info) # create uuid if it doesn't dev_uuid = dev_info.get('uuid', uuid.createString()) dev_info['uuid'] = dev_uuid @@ -654,9 +652,8 @@ class XendConfig(dict): sxpr.append(['up_time', str(uptime)]) sxpr.append(['start_time', str(self['start_time'])]) - sxpr.append(['autostart', self.get('autostart', 0)]) - sxpr.append(['autostop', self.get('autostop', 0)]) - sxpr.append(['on_xend_stop', self.get('on_xend_stop', 'shutdown')]) + sxpr.append(['on_xend_start', self.get('on_xend_start', 'ignore')]) + sxpr.append(['on_xend_stop', self.get('on_xend_stop', 'ignore')]) sxpr.append(['status', domain.state]) @@ -729,6 +726,8 @@ class XendConfig(dict): raise XendConfigError("XendConfig: device_add requires some " "config.") + log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) + if cfg_sxp: config = sxp.child0(cfg_sxp) dev_type = sxp.name(config) @@ -738,7 +737,6 @@ class XendConfig(dict): for opt, val in config[1:]: dev_info[opt] = val except ValueError: - log.debug('XendConfig.device_add: %s' % config) pass # SXP has no options for this device # create uuid if it doesn't exist diff -r d1f6aa51621f -r acb85833be66 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Thu Oct 05 18:22:13 2006 +0100 +++ b/tools/python/xen/xend/XendDomain.py Thu Oct 05 18:24:18 2006 +0100 @@ -523,8 +523,7 @@ class XendDomain: continue if dom.state == XendDomainInfo.DOM_STATE_RUNNING: - shouldShutdown = dom.info.get('autostop', 0) - shutdownAction = dom.info.get('on_xend_stop', 'shutdown') + shutdownAction = dom.info.get('on_xend_stop', 'ignore') if shouldShutdown and shutdownAction == 'shutdown': log.debug('Shutting down domain: %s' % dom.getName()) dom.shutdown("poweroff") diff -r d1f6aa51621f -r acb85833be66 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Thu Oct 05 18:22:13 2006 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Oct 05 18:24:18 2006 +0100 @@ -102,8 +102,7 @@ VM_STORE_ENTRIES = [ ('shadow_memory', int), ('maxmem', int), ('start_time', float), - ('autostart', int), - ('autostop', int), + ('on_xend_start', str), ('on_xend_stop', str), ] @@ -194,23 +193,28 @@ def recreate(info, priv): # entry disappears (eg. xenstore-rm /) # if domid != 0: - vmpath = xstransact.Read(dompath, "vm") - if not vmpath: - log.warn('/dom/%d/vm is missing. recreate is confused, trying ' - 'our best to recover' % domid) - needs_reinitialising = True - - uuid2_str = xstransact.Read(vmpath, "uuid") - if not uuid2_str: - log.warn('%s/uuid/ is missing. recreate is confused, trying ' - 'our best to recover' % vmpath) - needs_reinitialising = True - - uuid2 = uuid.fromString(uuid2_str) - if uuid1 != uuid2: - log.warn('UUID in /vm does not match the UUID in /dom/%d.' - 'Trying out best to recover' % domid) - needs_reinitialising = True + try: + vmpath = xstransact.Read(dompath, "vm") + if not vmpath: + log.warn('/dom/%d/vm is missing. recreate is confused, ' + 'trying our best to recover' % domid) + needs_reinitialising = True + raise XendError('reinit') + + uuid2_str = xstransact.Read(vmpath, "uuid") + if not uuid2_str: + log.warn('%s/uuid/ is missing. recreate is confused, ' + 'trying our best to recover' % vmpath) + needs_reinitialising = True + raise XendError('reinit') + + uuid2 = uuid.fromString(uuid2_str) + if uuid1 != uuid2: + log.warn('UUID in /vm does not match the UUID in /dom/%d.' + 'Trying out best to recover' % domid) + needs_reinitialising = True + except XendError: + pass # our best shot at 'goto' in python :) vm = XendDomainInfo(xeninfo, domid, dompath, augment = True, priv = priv) @@ -263,7 +267,6 @@ def createDormant(xeninfo): # Remove domid and uuid do not make sense for non-running domains. xeninfo.pop('domid', None) - xeninfo.pop('uuid', None) vm = XendDomainInfo(XendConfig(cfg = xeninfo)) return vm @@ -506,10 +509,11 @@ class XendDomainInfo: @param dev_config: device configuration @type dev_config: dictionary (parsed config) """ + log.debug("XendDomainInfo.device_create: %s" % dev_config) dev_type = sxp.name(dev_config) devid = self._createDevice(dev_type, dev_config) + self.info.device_add(dev_type, cfg_sxp = dev_config) self._waitForDevice(dev_type, devid) - self.info.device_add(dev_type, cfg_sxp = dev_config) return self.getDeviceController(dev_type).sxpr(devid) def device_configure(self, dev_config, devid): @@ -622,7 +626,7 @@ class XendDomainInfo: if not self.info['device'] and devices is not None: for device in devices: - self.info.device_add(device[0], cfg_sxp = device[1]) + self.info.device_add(device[0], cfg_sxp = device) # # Function to update xenstore /vm/* diff -r d1f6aa51621f -r acb85833be66 tools/python/xen/xm/create.py --- a/tools/python/xen/xm/create.py Thu Oct 05 18:22:13 2006 +0100 +++ b/tools/python/xen/xm/create.py Thu Oct 05 18:24:18 2006 +0100 @@ -439,17 +439,14 @@ gopts.var('uuid', val='', addresses for virtual network interfaces. This must be a unique value across the entire cluster.""") -gopts.var('autostart', val='no|yes', - fn=set_bool, default=0, - use="Should the start VM automatically when Xend starts.") - -gopts.var('autostop', val='no|yes', - fn=set_bool, default=0, - use="Should stop VM automatically when Xend stops.") - -gopts.var('on_xend_stop', val='shtudown|suspend', - fn=set_value, default="shutdown", - use="""Behaviour when Xend stops and autostop is on: +gopts.var('on_xend_start', val='ignore|start', + fn=set_value, default='ignore', + use='Action to perform when xend starts') + +gopts.var('on_xend_stop', val='continue|shutdown|suspend', + fn=set_value, default="ignore", + use="""Behaviour when Xend stops: + - ignore: Domain continues to run; - shutdown: Domain is shutdown; - suspend: Domain is suspended; """) @@ -685,7 +682,7 @@ def make_config(vals): map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory', 'restart', 'on_poweroff', 'on_reboot', 'on_crash', 'vcpus', 'features', - 'autostart', 'autostop', 'on_xend_stop']) + 'on_xend_start', 'on_xend_stop']) if vals.uuid is not None: config.append(['uuid', vals.uuid]) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |