aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-05-24 14:02:09 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-05-24 14:02:09 +0100
commit565f279e0732f15734ee8cf25a393bbf42a80072 (patch)
treea2c4e2bb78d9df7c2ed593a34ebb8ef4cdc775ff
parentff3ee9191483e231624020c619bfec83820ddea6 (diff)
downloadxen-565f279e0732f15734ee8cf25a393bbf42a80072.tar.gz
xen-565f279e0732f15734ee8cf25a393bbf42a80072.tar.bz2
xen-565f279e0732f15734ee8cf25a393bbf42a80072.zip
xend: Fix CPU affinity reset across save/restore.
Fixes bug #936. Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
-rw-r--r--tools/python/xen/xend/XendConfig.py64
1 files changed, 41 insertions, 23 deletions
diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py
index 14e0444df8..397fc437e8 100644
--- a/tools/python/xen/xend/XendConfig.py
+++ b/tools/python/xen/xend/XendConfig.py
@@ -587,30 +587,46 @@ class XendConfig(dict):
else:
cfg['cpus'] = str(cfg['cpu'])
- # convert 'cpus' string to list of ints
- # 'cpus' supports a list of ranges (0-3), seperated by
- # commas, and negation, (^1).
- # Precedence is settled by order of the string:
- # "0-3,^1" -> [0,2,3]
- # "0-3,^1,1" -> [0,1,2,3]
- try:
- if 'cpus' in cfg and type(cfg['cpus']) != list:
- cpus = []
- for c in cfg['cpus'].split(','):
- if c.find('-') != -1:
- (x, y) = c.split('-')
- for i in range(int(x), int(y)+1):
- cpus.append(int(i))
- else:
- # remove this element from the list
- if c[0] == '^':
- cpus = [x for x in cpus if x != int(c[1:])]
+ # Convert 'cpus' to list of ints
+ if 'cpus' in cfg:
+ cpus = []
+ if type(cfg['cpus']) == list:
+ # If sxp_cfg was created from config.sxp,
+ # the form of 'cpus' is list of string.
+ # Convert 'cpus' to list of ints.
+ # ['1'] -> [1]
+ # ['0','2','3'] -> [0,2,3]
+ try:
+ for c in cfg['cpus']:
+ cpus.append(int(c))
+
+ cfg['cpus'] = cpus
+ except ValueError, e:
+ raise XendConfigError('cpus = %s: %s' % (cfg['cpus'], e))
+ else:
+ # Convert 'cpus' string to list of ints
+ # 'cpus' supports a list of ranges (0-3),
+ # seperated by commas, and negation, (^1).
+ # Precedence is settled by order of the
+ # string:
+ # "0-3,^1" -> [0,2,3]
+ # "0-3,^1,1" -> [0,1,2,3]
+ try:
+ for c in cfg['cpus'].split(','):
+ if c.find('-') != -1:
+ (x, y) = c.split('-')
+ for i in range(int(x), int(y)+1):
+ cpus.append(int(i))
else:
- cpus.append(int(c))
-
- cfg['cpus'] = cpus
- except ValueError, e:
- raise XendConfigError('cpus = %s: %s' % (cfg['cpus'], e))
+ # remove this element from the list
+ if c[0] == '^':
+ cpus = [x for x in cpus if x != int(c[1:])]
+ else:
+ cpus.append(int(c))
+
+ cfg['cpus'] = cpus
+ except ValueError, e:
+ raise XendConfigError('cpus = %s: %s' % (cfg['cpus'], e))
if 'security' in cfg and isinstance(cfg['security'], str):
cfg['security'] = sxp.from_string(cfg['security'])
@@ -842,6 +858,8 @@ class XendConfig(dict):
if name in self and self[name] not in (None, []):
if typ == dict:
s = self[name].items()
+ elif typ == list:
+ s = self[name]
else:
s = str(self[name])
sxpr.append([name, s])