All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [Bug 936] Fix "cpus" in config.sxp
@ 2007-03-27 15:42 Masaki Kanno
  2007-03-30 16:44 ` Masaki Kanno
  0 siblings, 1 reply; 2+ messages in thread
From: Masaki Kanno @ 2007-03-27 15:42 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 730 bytes --]

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". 

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>

Best regards,
 Kan


[-- Attachment #2: bug936.patch --]
[-- Type: application/octet-stream, Size: 3735 bytes --]

diff -r 10fcea8f51cd tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py	Mon Mar 26 14:10:19 2007 +0100
+++ b/tools/python/xen/xend/XendConfig.py	Tue Mar 27 21:48:14 2007 +0900
@@ -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])

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [Bug 936] Fix "cpus" in config.sxp
  2007-03-27 15:42 [PATCH] [Bug 936] Fix "cpus" in config.sxp Masaki Kanno
@ 2007-03-30 16:44 ` Masaki Kanno
  0 siblings, 0 replies; 2+ messages in thread
From: Masaki Kanno @ 2007-03-30 16:44 UTC (permalink / raw)
  To: xen-devel, ewan

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

>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". 
>
>Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
>
>Best regards,
> Kan
>
>
>-------------------------------text/plain-------------------------------
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-30 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-27 15:42 [PATCH] [Bug 936] Fix "cpus" in config.sxp Masaki Kanno
2007-03-30 16:44 ` Masaki Kanno

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.