ia64/xen-unstable

changeset 15629:e934846666e6

Improve xm vcpu-list command for inactive managed domains.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Thu Jul 19 17:17:25 2007 +0100 (2007-07-19)
parents f85acff5bef5
children 9c3a8ca0bf34
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jul 19 17:15:49 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jul 19 17:17:25 2007 +0100
     1.3 @@ -632,16 +632,27 @@ class XendDomainInfo:
     1.4                      ['vcpu_count', self.info['VCPUs_max']]]
     1.5  
     1.6              for i in range(0, self.info['VCPUs_max']):
     1.7 -                info = xc.vcpu_getinfo(self.domid, i)
     1.8 -
     1.9 -                sxpr.append(['vcpu',
    1.10 -                             ['number',   i],
    1.11 -                             ['online',   info['online']],
    1.12 -                             ['blocked',  info['blocked']],
    1.13 -                             ['running',  info['running']],
    1.14 -                             ['cpu_time', info['cpu_time'] / 1e9],
    1.15 -                             ['cpu',      info['cpu']],
    1.16 -                             ['cpumap',   info['cpumap']]])
    1.17 +                if self.domid is not None:
    1.18 +                    info = xc.vcpu_getinfo(self.domid, i)
    1.19 +
    1.20 +                    sxpr.append(['vcpu',
    1.21 +                                 ['number',   i],
    1.22 +                                 ['online',   info['online']],
    1.23 +                                 ['blocked',  info['blocked']],
    1.24 +                                 ['running',  info['running']],
    1.25 +                                 ['cpu_time', info['cpu_time'] / 1e9],
    1.26 +                                 ['cpu',      info['cpu']],
    1.27 +                                 ['cpumap',   info['cpumap']]])
    1.28 +                else:
    1.29 +                    sxpr.append(['vcpu',
    1.30 +                                 ['number',   i],
    1.31 +                                 ['online',   0],
    1.32 +                                 ['blocked',  0],
    1.33 +                                 ['running',  0],
    1.34 +                                 ['cpu_time', 0.0],
    1.35 +                                 ['cpu',      -1],
    1.36 +                                 ['cpumap',   self.info['cpus'] and \
    1.37 +                                              self.info['cpus'] or range(64)]])
    1.38  
    1.39              return sxpr
    1.40  
     2.1 --- a/tools/python/xen/xm/main.py	Thu Jul 19 17:15:49 2007 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Thu Jul 19 17:17:25 2007 +0100
     2.3 @@ -1023,13 +1023,13 @@ def xm_vcpu_list(args):
     2.4          if args:
     2.5              dominfo = map(server.xend.domain.getVCPUInfo, args)
     2.6          else:
     2.7 -            doms = server.xend.domains(False)
     2.8 +            doms = server.xend.domains_with_state(False, 'all', False)
     2.9              dominfo = map(server.xend.domain.getVCPUInfo, doms)
    2.10  
    2.11      print '%-32s %5s %5s %5s %5s %9s %s' % \
    2.12            ('Name', 'ID', 'VCPU', 'CPU', 'State', 'Time(s)', 'CPU Affinity')
    2.13  
    2.14 -    format = '%(name)-32s %(domid)5d %(number)5d %(c)5s %(s)5s ' \
    2.15 +    format = '%(name)-32s %(domid)5s %(number)5d %(c)5s %(s)5s ' \
    2.16               ' %(cpu_time)8.1f %(cpumap)s'
    2.17  
    2.18      for dom in dominfo:
    2.19 @@ -1098,8 +1098,12 @@ def xm_vcpu_list(args):
    2.20  
    2.21              return format_pairs(list_to_rangepairs(cpumap))
    2.22  
    2.23 -        name  =     get_info('name')
    2.24 -        domid = int(get_info('domid'))
    2.25 +        name  = get_info('name')
    2.26 +        domid = get_info('domid')
    2.27 +        if domid is not None:
    2.28 +            domid = str(domid)
    2.29 +        else:
    2.30 +            domid = ''
    2.31  
    2.32          for vcpu in sxp.children(dom, 'vcpu'):
    2.33              def vinfo(n, t):
    2.34 @@ -1113,7 +1117,10 @@ def xm_vcpu_list(args):
    2.35              running  = vinfo('running',  int)
    2.36              blocked  = vinfo('blocked',  int)
    2.37  
    2.38 -            if online:
    2.39 +            if cpu < 0:
    2.40 +                c = ''
    2.41 +                s = ''
    2.42 +            elif online:
    2.43                  c = str(cpu)
    2.44                  if running:
    2.45                      s = 'r'
    2.46 @@ -1125,8 +1132,8 @@ def xm_vcpu_list(args):
    2.47                      s += '-'
    2.48                  s += '-'
    2.49              else:
    2.50 -                c = "-"
    2.51 -                s = "--p"
    2.52 +                c = '-'
    2.53 +                s = '--p'
    2.54  
    2.55              print format % locals()
    2.56