Fix "cpus" in config.sxp
PATCH 1/1 Fix "cpus" in config.sxp
Hi,
I fixed the Xen bugzilla 936.
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=936
Currently, "cpus" output to config.sxp is the following form. Therefore _parse_sxp() cannot convert '[1' to integer.
e.g. (cpus '[1, 2]') --- string
This patch changes output form of "cpus". The form is as follows.
e.g. (cpus (1 2))
However, the bug cannot be solved only by the change. When xend is started, "cpus" of the SXP configuration passes to _parse_sxp() in the following form.
e.g. ['cpus': ['1', '2']] --- list of string
Therefore this patch adds proceeding of to convert list of string to list of integer for "cpus".
Best regards,
Kan
tools/python/xen/xend/XendConfig.py +41 -23
@@ -585,30 +585,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'])
@@ -840,6 +856,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])
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi Ewan,
Could you apply this patch?
If without it, we must register domains by using the xm new command whenever we start xend.
Or have you already prepared other patch which can solve this issue? If so, could you include it in Xen3.0.5?
Best regards,
Kan
Quoted 34 lines
Hi,
I fixed the Xen bugzilla 936.
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=936Currently, "cpus" output to config.sxp is the following form. Therefore
_parse_sxp()cannot convert '[1' to integer.e.g. (cpus '[1, 2]') --- string
This patch changes output form of "cpus". The form is as follows.
e.g. (cpus (1 2))
However, the bug cannot be solved only by the change. When xend is started, "cpus" of the SXP configuration passes to
_parse_sxp()in the following form.e.g. ['cpus': ['1', '2']] --- list of string
Therefore this patch adds proceeding of to convert list of string to list of integer for "cpus".
Signed-off-by Masaki Kanno <[email protected]>Best regards,
Kan-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel