direct-io.hg

changeset 13283:69579f9f1c81

[TOOLS] Improve information displayed by the xm sched-credit command.

The improvement is as follows.
1. The display form is changed like the xm sched-sedf command.
2. When -d option is omitted, information on all domains is
displayed.

Examples:
# xm sched-credit -d vm1
Name ID Weight Cap
vm1 1 512 100
# xm sched-credit
Name ID Weight Cap
Domain-0 0 256 0
vm1 1 512 100
vm2 2 512 50

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Sat Jan 06 11:17:52 2007 +0000 (2007-01-06)
parents 9865145e53eb
children d3e40fd6038e
files tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Fri Jan 05 18:17:36 2007 +0000
     1.2 +++ b/tools/python/xen/xm/main.py	Sat Jan 06 11:17:52 2007 +0000
     1.3 @@ -130,7 +130,7 @@ SUBCOMMAND_HELP = {
     1.4      'log'         : ('', 'Print Xend log'),
     1.5      'rename'      : ('<Domain> <NewDomainName>', 'Rename a domain.'),
     1.6      'sched-sedf'  : ('<Domain> [options]', 'Get/set EDF parameters.'),
     1.7 -    'sched-credit': ('-d <Domain> [-w[=WEIGHT]|-c[=CAP]]',
     1.8 +    'sched-credit': ('[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]',
     1.9                       'Get/set credit scheduler parameters.'),
    1.10      'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
    1.11      'vcpu-list'   : ('[<Domain>]',
    1.12 @@ -717,6 +717,10 @@ def parse_sedf_info(info):
    1.13          'weight'   : get_info('weight',        int,   -1),
    1.14          }
    1.15  
    1.16 +def domid_match(domid, info):
    1.17 +    return domid is None or domid == info['name'] or \
    1.18 +           domid == str(info['domid'])
    1.19 +
    1.20  def xm_brief_list(doms):
    1.21      print '%-40s %3s %5s %5s %10s %9s' % \
    1.22            ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)')
    1.23 @@ -1091,10 +1095,6 @@ def xm_sched_sedf(args):
    1.24          print( ("%(name)-32s %(domid)3d %(period)9.1f %(slice)9.1f" +
    1.25                  " %(latency)7.1f %(extratime)6d %(weight)6d") % info)
    1.26  
    1.27 -    def domid_match(domid, info):
    1.28 -        return domid is None or domid == info['name'] or \
    1.29 -               domid == str(info['domid'])
    1.30 -
    1.31      # we want to just display current info if no parameters are passed
    1.32      if len(args) == 0:
    1.33          domid = None
    1.34 @@ -1174,27 +1174,43 @@ def xm_sched_credit(args):
    1.35          err(opterr)
    1.36          usage('sched-credit')
    1.37  
    1.38 -    domain = None
    1.39 +    domid = None
    1.40      weight = None
    1.41      cap = None
    1.42  
    1.43      for o, a in opts:
    1.44          if o == "-d":
    1.45 -            domain = a
    1.46 +            domid = a
    1.47          elif o == "-w":
    1.48              weight = int(a)
    1.49          elif o == "-c":
    1.50              cap = int(a);
    1.51  
    1.52 -    if domain is None:
    1.53 -        # place holder for system-wide scheduler parameters
    1.54 -        err("No domain given.")
    1.55 -        usage('sched-credit')
    1.56 +    doms = filter(lambda x : domid_match(domid, x),
    1.57 +                  [parse_doms_info(dom)
    1.58 +                  for dom in getDomains(None, 'running')])
    1.59  
    1.60      if weight is None and cap is None:
    1.61 -        print server.xend.domain.sched_credit_get(domain)
    1.62 +        # print header if we aren't setting any parameters
    1.63 +        print '%-33s %-2s %-6s %-4s' % ('Name','ID','Weight','Cap')
    1.64 +        
    1.65 +        for d in doms:
    1.66 +            try:
    1.67 +                info = server.xend.domain.sched_credit_get(d['domid'])
    1.68 +            except xmlrpclib.Fault:
    1.69 +                # domain does not support sched-credit?
    1.70 +                info = {'weight': -1, 'cap': -1}
    1.71 +            
    1.72 +            info['name']  = d['name']
    1.73 +            info['domid'] = int(d['domid'])
    1.74 +            print( ("%(name)-32s %(domid)3d %(weight)6d %(cap)4d") % info)
    1.75      else:
    1.76 -        result = server.xend.domain.sched_credit_set(domain, weight, cap)
    1.77 +        if domid is None:
    1.78 +            # place holder for system-wide scheduler parameters
    1.79 +            err("No domain given.")
    1.80 +            usage('sched-credit')
    1.81 +        
    1.82 +        result = server.xend.domain.sched_credit_set(domid, weight, cap)
    1.83          if result != 0:
    1.84              err(str(result))
    1.85