direct-io.hg

changeset 7474:a2cf10b8da5a

Fix 'xm vcpu-list'. List cpumap as 'CPU Affinity'. Use
special descriptive strings for empty and full cpu maps.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Oct 22 10:33:26 2005 +0100 (2005-10-22)
parents 94cee9a918de
children 6f8ce90246f8
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Sat Oct 22 08:35:03 2005 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Sat Oct 22 10:33:26 2005 +0100
     1.3 @@ -274,7 +274,7 @@ def xm_brief_list(doms):
     1.4  
     1.5  
     1.6  def xm_vcpu_list(args):
     1.7 -    print 'Name                              ID  VCPU  CPU  State  Time(s)  CPU Map'
     1.8 +    print 'Name                              ID  VCPU  CPU  State  Time(s)  CPU Affinity'
     1.9  
    1.10      from xen.xend.XendClient import server
    1.11      if args:
    1.12 @@ -319,6 +319,8 @@ def xm_vcpu_list(args):
    1.13          # Convert pairs to range string, e.g: [(1,2),(3,3),(5,7)] -> 1-2,3,5-7
    1.14          #
    1.15          def format_pairs(pairs):
    1.16 +            if not pairs:
    1.17 +                return "no cpus"
    1.18              out = ""
    1.19              for f,s in pairs:
    1.20                  if (f==s):
    1.21 @@ -330,25 +332,23 @@ def xm_vcpu_list(args):
    1.22              return out[:-1]
    1.23  
    1.24          def format_cpumap(cpumap):
    1.25 -            def uniq(x):
    1.26 -               return [ u for u in x if u not in locals()['_[1]'] ]
    1.27 +            cpumap = map(lambda x: int(x), cpumap)
    1.28 +            cpumap.sort()
    1.29  
    1.30              from xen.xend.XendClient import server
    1.31              for x in server.xend_node()[1:]:
    1.32                  if len(x) > 1 and x[0] == 'nr_cpus':
    1.33                      nr_cpus = int(x[1])
    1.34 +                    cpumap = filter(lambda x: x < nr_cpus, cpumap)
    1.35 +                    if len(cpumap) == nr_cpus:
    1.36 +                        return "any cpu"
    1.37                      break
    1.38   
    1.39 -            return format_pairs(
    1.40 -                          list_to_rangepairs(
    1.41 -                              map(lambda x: x % nr_cpus, 
    1.42 -                                  uniq(map(lambda x: int(x), cpumap)) )))
    1.43 -                
    1.44 +            return format_pairs(list_to_rangepairs(cpumap))
    1.45  
    1.46          name  =     get_info('name')
    1.47          domid = int(get_info('domid'))
    1.48  
    1.49 -
    1.50          for vcpu in sxp.children(dom, 'vcpu'):
    1.51              def vinfo(n, t):
    1.52                  return t(sxp.child_value(vcpu, n))