ia64/xen-unstable

changeset 9233:ed1afb12106e

- Reworked to use your match_domid suggestion and filtering
- Aligned output and help to fit within 80 char limit
- User now deals in milliseconds instead of nanoseconds
- Fixed some missing parens in tests (I had pushed stale versions)
- Updated tests to deal with period/slice/latency in ms

root@bebop:~/xm-test.sedf/tests/sedf # xm sched-sedf
Name ID Period(ms) Slice(ms) Lat(ms) Extra Weight
Domain-0 0 20.0 15.0 0.0 1 0

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Sat Mar 11 11:45:10 2006 +0100 (2006-03-11)
parents 90bac1d23a0c
children e48f56250811 000d5ccb2bec
files tools/python/xen/xm/main.py tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py tools/xm-test/tests/sedf/05_sedf_extratime_pos.py tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py
line diff
     1.1 --- a/tools/python/xen/xm/main.py	Sat Mar 11 11:20:32 2006 +0100
     1.2 +++ b/tools/python/xen/xm/main.py	Sat Mar 11 11:45:10 2006 +0100
     1.3 @@ -84,10 +84,11 @@ sched_bvt_help = """sched-bvt <Parameter
     1.4  sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow>       Set the BVT scheduler context switch
     1.5                                      allowance"""
     1.6  sched_sedf_help = "sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF parameters\n" + \
     1.7 -"              -p, --period          Relative deadline(ns).\n\
     1.8 -              -s, --slice           Worst-case execution time(ns) (slice < period).\n\
     1.9 -              -l, --latency         scaled period(ns) in case the domain is doing\n\
    1.10 -                                    heavy I/O.\n\
    1.11 +"              -p, --period          Relative deadline(ms).\n\
    1.12 +              -s, --slice           Worst-case execution time(ms)\n\
    1.13 +                                    (slice < period).\n\
    1.14 +              -l, --latency         scaled period(ms) in case the domain\n\
    1.15 +                                    is doing heavy I/O.\n\
    1.16                -e, --extra           flag (0/1) which controls whether the\n\
    1.17                                      domain can run in extra-time\n\
    1.18                -w, --weight          mutually exclusive with period/slice and\n\
    1.19 @@ -641,26 +642,25 @@ def xm_sched_bvt_ctxallow(args):
    1.20      server.xend_node_cpu_bvt_slice_set(slice)
    1.21  
    1.22  def xm_sched_sedf(args):
    1.23 +    def ns_to_ms(val):
    1.24 +        return float(val) * 0.000001
    1.25 +    
    1.26 +    def ms_to_ns(val):
    1.27 +        return (float(val) / 0.000001)
    1.28 +
    1.29      def print_sedf(info):
    1.30 -        print( ("%(name)-32s %(dom)3d %(period)12d %(slice)12d %(latency)12d" +
    1.31 -                " %(extratime)10d %(weight)7d") % info)
    1.32 +        info['period']  = ns_to_ms(info['period'])
    1.33 +        info['slice']   = ns_to_ms(info['slice'])
    1.34 +        info['latency'] = ns_to_ms(info['latency'])
    1.35 +        print( ("%(name)-32s %(dom)3d %(period)9.1f %(slice)9.1f" +
    1.36 +                " %(latency)7.1f %(extratime)6d %(weight)6d") % info)
    1.37  
    1.38 -    # FIXME: this can probably go away if someone points me to the proper way.
    1.39      def domid_match(domid, info):
    1.40 -        d = ""
    1.41 -        f = ""
    1.42 -        try:
    1.43 -            d = int(domid)
    1.44 -            f = 'dom'
    1.45 -        except:
    1.46 -            d = domid 
    1.47 -            f = 'name'
    1.48 +        return domid is None or domid == info['name'] or domid == str(info['dom'])
    1.49  
    1.50 -        return (d == info[f])
    1.51 -          
    1.52      # we want to just display current info if no parameters are passed
    1.53      if len(args) == 0:
    1.54 -        domid = '-1'
    1.55 +        domid = None
    1.56      else:
    1.57          # we expect at least a domain id (name or number)
    1.58          # and at most a domid up to 5 options with values
    1.59 @@ -677,13 +677,14 @@ def xm_sched_sedf(args):
    1.60          err(opterr)
    1.61          sys.exit(1)
    1.62      
    1.63 +    # convert to nanoseconds if needed 
    1.64      for (k, v) in options:
    1.65          if k in ['-p', '--period']:
    1.66 -            opts['period'] = v
    1.67 +            opts['period'] = ms_to_ns(v)
    1.68          elif k in ['-s', '--slice']:
    1.69 -            opts['slice'] = v
    1.70 +            opts['slice'] = ms_to_ns(v)
    1.71          elif k in ['-l', '--latency']:
    1.72 -            opts['latency'] = v
    1.73 +            opts['latency'] = ms_to_ns(v)
    1.74          elif k in ['-e', '--extratime']:
    1.75              opts['extratime'] = v
    1.76          elif k in ['-w', '--weight']:
    1.77 @@ -691,37 +692,35 @@ def xm_sched_sedf(args):
    1.78  
    1.79      # print header if we aren't setting any parameters
    1.80      if len(opts.keys()) == 0:
    1.81 -        print '%-33s %-8s %-13s %-10s %-8s %-10s %-6s' %('Name','ID','Period',
    1.82 -                                                         'Slice', 'Latency',
    1.83 -                                                         'ExtraTime','Weight')
    1.84 +        print '%-33s %-2s %-4s %-4s %-7s %-5s %-6s'%('Name','ID','Period(ms)',
    1.85 +                                                     'Slice(ms)', 'Lat(ms)',
    1.86 +                                                     'Extra','Weight')
    1.87  
    1.88      from xen.xend.XendClient import server
    1.89 -    for dom in getDomains(""):
    1.90 -        d = parse_doms_info(dom)
    1.91 -        
    1.92 -        if domid == '-1' or domid_match(domid, d):
    1.93 -
    1.94 -            # fetch current values so as not to clobber them
    1.95 -            sedf_info = \
    1.96 -                parse_sedf_info(server.xend_domain_cpu_sedf_get(d['dom']))
    1.97 -            sedf_info['name'] = d['name']
    1.98 +    doms = filter(lambda x : domid_match(domid, x),
    1.99 +                        [parse_doms_info(dom) for dom in getDomains("")])
   1.100 +    for d in doms:
   1.101 +        # fetch current values so as not to clobber them
   1.102 +        sedf_info = \
   1.103 +            parse_sedf_info(server.xend_domain_cpu_sedf_get(d['dom']))
   1.104 +        sedf_info['name'] = d['name']
   1.105  
   1.106 -            # update values in case of call to set
   1.107 -            if len(opts.keys()) > 0:
   1.108 -                for k in opts.keys():
   1.109 -                    sedf_info[k]=opts[k]
   1.110 -            
   1.111 -                # send the update
   1.112 -                v = map(int, [sedf_info['period'],  sedf_info['slice'],
   1.113 -                              sedf_info['latency'], sedf_info['extratime'],
   1.114 -                              sedf_info['weight']])
   1.115 -                rv = server.xend_domain_cpu_sedf_set(d['dom'], *v)
   1.116 -                if int(rv) != 0:
   1.117 -                    err("Failed to set sedf parameters (rv=%d)."%(rv))
   1.118 +        # update values in case of call to set
   1.119 +        if len(opts.keys()) > 0:
   1.120 +            for k in opts.keys():
   1.121 +                sedf_info[k]=opts[k]
   1.122 +         
   1.123 +            # send the update, converting user input
   1.124 +            v = map(int, [sedf_info['period'], sedf_info['slice'],
   1.125 +                          sedf_info['latency'],sedf_info['extratime'], 
   1.126 +                          sedf_info['weight']])
   1.127 +            rv = server.xend_domain_cpu_sedf_set(d['dom'], *v)
   1.128 +            if int(rv) != 0:
   1.129 +                err("Failed to set sedf parameters (rv=%d)."%(rv))
   1.130  
   1.131 -            # not setting values, display info
   1.132 -            else:
   1.133 -                print_sedf(sedf_info)
   1.134 +        # not setting values, display info
   1.135 +        else:
   1.136 +            print_sedf(sedf_info)
   1.137  
   1.138  
   1.139  def xm_info(args):
     2.1 --- a/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py	Sat Mar 11 11:20:32 2006 +0100
     2.2 +++ b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py	Sat Mar 11 11:45:10 2006 +0100
     2.3 @@ -33,8 +33,8 @@ if status != 0:
     2.4  
     2.5  # NB: setting period requires non-zero slice 
     2.6  # scale current period in half
     2.7 -period = str(int(p) / 2)
     2.8 -slice  = str(int(p) / 4)
     2.9 +period = str(float(p) / 2)
    2.10 +slice  = str(float(p) / 4)
    2.11  
    2.12  opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
    2.13  (status, output) = traceCommand("xm sched-sedf %s" %(opts))
    2.14 @@ -53,10 +53,10 @@ if s != 0:
    2.15  (name,domid,p1,s1,l1,e1,w1) = params
    2.16  
    2.17  if p1 != period:
    2.18 -    FAIL("Failed to change domain period from %d to %d" %(p, period))
    2.19 +    FAIL("Failed to change domain period from %f to %f" %(p, period))
    2.20  
    2.21  if s1 != slice:
    2.22 -    FAIL("Failed to change domain slice from %d to %d" %(s, slice))
    2.23 +    FAIL("Failed to change domain slice from %f to %f" %(s, slice))
    2.24  
    2.25  # Stop the domain (nice shutdown)
    2.26  domain.stop()
     3.1 --- a/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py	Sat Mar 11 11:20:32 2006 +0100
     3.2 +++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py	Sat Mar 11 11:45:10 2006 +0100
     3.3 @@ -28,7 +28,7 @@ period = "-1"
     3.4  
     3.5  # NB: setting period requires non-zero slice 
     3.6  # scale current period in half
     3.7 -slice  = "1"
     3.8 +slice  = "5"
     3.9  
    3.10  opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
    3.11  (status, output) = traceCommand("xm sched-sedf %s" %(opts))
    3.12 @@ -39,3 +39,6 @@ eyecatcher = "Failed to set sedf paramet
    3.13  # check for failure
    3.14  if output.find(eyecatcher) >= 0:
    3.15      FAIL("sched-sedf let me set bogus period (%s)" %(period))
    3.16 +
    3.17 +# Stop the domain (nice shutdown)
    3.18 +domain.stop()
     4.1 --- a/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py	Sat Mar 11 11:20:32 2006 +0100
     4.2 +++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py	Sat Mar 11 11:45:10 2006 +0100
     4.3 @@ -34,4 +34,7 @@ eyecatcher = "Failed to set sedf paramet
     4.4  
     4.5  # check for failure
     4.6  if output.find(eyecatcher) >= 0:
     4.7 -    FAIL("sched-sedf let me set bogus slice (%s)" %(slice)
     4.8 +    FAIL("sched-sedf let me set bogus slice (%s)" %(slice))
     4.9 +
    4.10 +# Stop the domain (nice shutdown)
    4.11 +domain.stop()
     5.1 --- a/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py	Sat Mar 11 11:20:32 2006 +0100
     5.2 +++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py	Sat Mar 11 11:45:10 2006 +0100
     5.3 @@ -32,7 +32,7 @@ if status != 0:
     5.4  (name, domid, p, s, l, e, w) = params
     5.5  
     5.6  # set slice > than current period
     5.7 -slice  = str(int(p)+1)
     5.8 +slice  = str(float(p)+1)
     5.9  
    5.10  opts = "%s -s %s" %(domain.getName(), slice)
    5.11  (status, output) = traceCommand("xm sched-sedf %s" %(opts))
    5.12 @@ -43,3 +43,6 @@ eyecatcher = "Failed to set sedf paramet
    5.13  # check for failure
    5.14  if output.find(eyecatcher) >= 0:
    5.15      FAIL("sched-sedf let me set a slice bigger than my period.")
    5.16 +
    5.17 +# Stop the domain (nice shutdown)
    5.18 +domain.stop()
     6.1 --- a/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py	Sat Mar 11 11:20:32 2006 +0100
     6.2 +++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py	Sat Mar 11 11:45:10 2006 +0100
     6.3 @@ -38,7 +38,7 @@ direction = "disable"
     6.4  # NB: when disabling extratime(=0), must pass in a slice
     6.5  opts = "%s -e %s" %(domain.getName(), extratime)
     6.6  if extratime == "0":
     6.7 -    opts += " -s %s" %( str( (int(p)/2)+1 ) )
     6.8 +    opts += " -s %s" %( str( (float(p)/2)+1 ) )
     6.9      direction = "enable"
    6.10      
    6.11  (status, output) = traceCommand("xm sched-sedf %s" %(opts))
     7.1 --- a/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py	Sat Mar 11 11:20:32 2006 +0100
     7.2 +++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py	Sat Mar 11 11:45:10 2006 +0100
     7.3 @@ -66,3 +66,6 @@ eyecatcher = "Failed to set sedf paramet
     7.4  # check for failure
     7.5  if output.find(eyecatcher) >= 0:
     7.6      FAIL("sched-sedf let me disable extratime without a non-zero slice")
     7.7 +
     7.8 +# Stop the domain (nice shutdown)
     7.9 +domain.stop()