[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] This patch



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 3ea1c6118fc27e8383ed3169ab6009026505b168
# Parent  8c1badb84c3ed6160822771441d68151b1f62052
This patch

-Displays current parameters for running domains ala xm list
-Allow users to set one or more parameters without having to
 provide values for parameters they do not wish to change
-Adds additional testing of sched-sedf via new xm-test testcases.

With this patch applied, test 02_sedf_period_lower_neg.py exposes a
bug.  I'll follow up this email with a patch for the bug.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>

diff -r 8c1badb84c3e -r 3ea1c6118fc2 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu Mar  9 23:49:54 2006
+++ b/tools/python/xen/xend/XendDomain.py       Fri Mar 10 00:08:59 2006
@@ -487,7 +487,17 @@
         """
         dominfo = self.domain_lookup(domid)
         try:
-            return xc.sedf_domain_get(dominfo.getDomid())
+            
+            sedf_info = xc.sedf_domain_get(dominfo.getDomid())
+            # return sxpr
+            return ['sedf',
+                    ['domain',    sedf_info['domain']],
+                    ['period',    sedf_info['period']],
+                    ['slice',     sedf_info['slice']],
+                    ['latency',   sedf_info['latency']],
+                    ['extratime', sedf_info['extratime']],
+                    ['weight',    sedf_info['weight']]]
+
         except Exception, ex:
             raise XendError(str(ex))
 
diff -r 8c1badb84c3e -r 3ea1c6118fc2 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Mar  9 23:49:54 2006
+++ b/tools/python/xen/xm/main.py       Fri Mar 10 00:08:59 2006
@@ -83,7 +83,17 @@
                                     parameters"""
 sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow>       Set the BVT 
scheduler context switch
                                     allowance"""
-sched_sedf_help = "sched-sedf <Parameters>          Set simple EDF parameters"
+sched_sedf_help = "sched-sedf [DOM] [OPTIONS]       Show|Set simple EDF 
parameters\n" + \
+"              -p, --period          Relative deadline(ns).\n\
+              -s, --slice           Worst-case execution time(ns) (slice < 
period).\n\
+              -l, --latency         scaled period(ns) in case the domain is 
doing\n\
+                                    heavy I/O.\n\
+              -e, --extra           flag (0/1) which controls whether the\n\
+                                    domain can run in extra-time\n\
+              -w, --weight          mutually exclusive with period/slice and\n\
+                                    specifies another way of setting a 
domain's\n\
+                                    cpu period/slice."
+
 block_attach_help = """block-attach <DomId> <BackDev> <FrontDev> <Mode>
                 [BackDomId]         Create a new virtual block device"""
 block_detach_help = """block-detach  <DomId> <DevId>    Destroy a domain's 
virtual block device,
@@ -377,6 +387,20 @@
         }
 
 
+def parse_sedf_info(info):
+    def get_info(n, t, d):
+        return t(sxp.child_value(info, n, d))
+
+    return {
+        'dom'      : get_info('domain',        int,   -1),
+        'period'   : get_info('period',        int,   -1),
+        'slice'    : get_info('slice',         int,   -1),
+        'latency'  : get_info('latency',       int,   -1),
+        'extratime': get_info('extratime',     int,   -1),
+        'weight'   : get_info('weight',        int,   -1),
+        }
+
+
 def xm_brief_list(doms):
     print 'Name                              ID Mem(MiB) VCPUs State  Time(s)'
     for dom in doms:
@@ -617,12 +641,88 @@
     server.xend_node_cpu_bvt_slice_set(slice)
 
 def xm_sched_sedf(args):
-    arg_check(args, "sched-sedf", 6)
-    
-    dom = args[0]
-    v = map(int, args[1:6])
-    from xen.xend.XendClient import server
-    server.xend_domain_cpu_sedf_set(dom, *v)
+    def print_sedf(info):
+        print( ("%(name)-32s %(dom)3d %(period)12d %(slice)12d %(latency)12d" +
+                " %(extratime)10d %(weight)7d") % info)
+
+    # FIXME: this can probably go away if someone points me to the proper way.
+    def domid_match(domid, info):
+        d = ""
+        f = ""
+        try:
+            d = int(domid)
+            f = 'dom'
+        except:
+            d = domid 
+            f = 'name'
+
+        return (d == info[f])
+          
+    # we want to just display current info if no parameters are passed
+    if len(args) == 0:
+        domid = '-1'
+    else:
+        # we expect at least a domain id (name or number)
+        # and at most a domid up to 5 options with values
+        arg_check(args, "sched-sedf", 1, 11)
+        domid = args[0]
+        # drop domid from args since get_opt doesn't recognize it
+        args = args[1:] 
+
+    opts = {}
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'p:s:l:e:w:',
+            ['period=', 'slice=', 'latency=', 'extratime=', 'weight='])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        sys.exit(1)
+    
+    for (k, v) in options:
+        if k in ['-p', '--period']:
+            opts['period'] = v
+        elif k in ['-s', '--slice']:
+            opts['slice'] = v
+        elif k in ['-l', '--latency']:
+            opts['latency'] = v
+        elif k in ['-e', '--extratime']:
+            opts['extratime'] = v
+        elif k in ['-w', '--weight']:
+            opts['weight'] = v
+
+    # print header if we aren't setting any parameters
+    if len(opts.keys()) == 0:
+        print '%-33s %-8s %-13s %-10s %-8s %-10s %-6s' %('Name','ID','Period',
+                                                         'Slice', 'Latency',
+                                                         'ExtraTime','Weight')
+
+    from xen.xend.XendClient import server
+    for dom in getDomains(""):
+        d = parse_doms_info(dom)
+        
+        if domid == '-1' or domid_match(domid, d):
+
+            # fetch current values so as not to clobber them
+            sedf_info = \
+                parse_sedf_info(server.xend_domain_cpu_sedf_get(d['dom']))
+            sedf_info['name'] = d['name']
+
+            # update values in case of call to set
+            if len(opts.keys()) > 0:
+                for k in opts.keys():
+                    sedf_info[k]=opts[k]
+            
+                # send the update
+                v = map(int, [sedf_info['period'],  sedf_info['slice'],
+                              sedf_info['latency'], sedf_info['extratime'],
+                              sedf_info['weight']])
+                rv = server.xend_domain_cpu_sedf_set(d['dom'], *v)
+                if int(rv) != 0:
+                    err("Failed to set sedf parameters (rv=%d)."%(rv))
+
+            # not setting values, display info
+            else:
+                print_sedf(sedf_info)
+
 
 def xm_info(args):
     arg_check(args, "info", 0)
diff -r 8c1badb84c3e -r 3ea1c6118fc2 tools/xm-test/tests/sedf/Makefile.am
--- a/tools/xm-test/tests/sedf/Makefile.am      Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/Makefile.am      Fri Mar 10 00:08:59 2006
@@ -1,7 +1,9 @@
 
 SUBDIRS =
 
-TESTS = 01_sedf_multi_pos.test
+TESTS = 01_sedf_period_slice_pos.py 02_sedf_period_lower_neg.py \
+        03_sedf_slice_lower_neg.py  04_sedf_slice_upper_neg.py  \
+        05_sedf_extratime_pos.py 06_sedf_extratime_disable_neg.py
 
 XFAIL_TESTS = 
 
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py      Fri Mar 10 
00:08:59 2006
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# get current param values as baseline
+(status, params) = get_sedf_params(domain)
+
+# check rv
+if status != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)", status)
+
+# parse out current params
+(name, domid, p, s, l, e, w) = params
+
+# NB: setting period requires non-zero slice 
+# scale current period in half
+period = str(int(p) / 2)
+slice  = str(int(p) / 4)
+
+opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# check rv
+if status != 0:
+    FAIL("Setting sedf parameters return non-zero rv (%d)" % status)
+
+# validate 
+(s,params) = get_sedf_params(domain)
+
+# check rv
+if s != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)" % s)
+
+(name,domid,p1,s1,l1,e1,w1) = params
+
+if p1 != period:
+    FAIL("Failed to change domain period from %d to %d" %(p, period))
+
+if s1 != slice:
+    FAIL("Failed to change domain slice from %d to %d" %(s, slice))
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py      Fri Mar 10 
00:08:59 2006
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+#
+# Test if sched-sedf <dom> -p <period> handles lower bound 
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# pick bogus period
+period = "-1"
+
+# NB: setting period requires non-zero slice 
+# scale current period in half
+slice  = "1"
+
+opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# we should see this output from xm 
+eyecatcher = "Failed to set sedf parameters"
+
+# check for failure
+if output.find(eyecatcher) >= 0:
+    FAIL("sched-sedf let me set bogus period (%s)" %(period))
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py       Fri Mar 10 
00:08:59 2006
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+#
+# Test if sched-sedf <dom> -p <period> handles lower bound 
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# pick bogus slice
+slice  = "0"
+
+opts = "%s -s %s" %(domain.getName(), slice)
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# we should see this output from xm 
+eyecatcher = "Failed to set sedf parameters"
+
+# check for failure
+if output.find(eyecatcher) >= 0:
+    FAIL("sched-sedf let me set bogus slice (%s)" %(slice)
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py       Fri Mar 10 
00:08:59 2006
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# get current param values as baseline
+(status, params) = get_sedf_params(domain)
+
+# check rv
+if status != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)", status)
+
+# parse out current params
+(name, domid, p, s, l, e, w) = params
+
+# set slice > than current period
+slice  = str(int(p)+1)
+
+opts = "%s -s %s" %(domain.getName(), slice)
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# we should see this output from xm 
+eyecatcher = "Failed to set sedf parameters"
+
+# check for failure
+if output.find(eyecatcher) >= 0:
+    FAIL("sched-sedf let me set a slice bigger than my period.")
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/05_sedf_extratime_pos.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Fri Mar 10 00:08:59 2006
@@ -0,0 +1,63 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# get current param values as baseline
+(status, params) = get_sedf_params(domain)
+
+# check rv
+if status != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)", status)
+
+# parse out current params
+(name, domid, p, s, l, e, w) = params
+
+# toggle extratime value
+extratime = str((int(e)+1)%2)
+
+direction = "disable"
+# NB: when disabling extratime(=0), must pass in a slice
+opts = "%s -e %s" %(domain.getName(), extratime)
+if extratime == "0":
+    opts += " -s %s" %( str( (int(p)/2)+1 ) )
+    direction = "enable"
+    
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# check rv
+if status != 0:
+   FAIL("Setting sedf parameters return non-zero rv (%d)" % status)
+
+# validate
+(s,params) = get_sedf_params(domain)
+
+# check rv
+if s != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)" % s)
+
+(name,domid,p1,s1,l1,e1,w1) = params
+
+if e1 != extratime:
+    FAIL("Failed to %s extratime" %(direction))
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py
--- /dev/null   Thu Mar  9 23:49:54 2006
+++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Fri Mar 10 
00:08:59 2006
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@xxxxxxxxxx>
+# Author: Ryan Harper <ryanh@xxxxxxxxxx>
+
+from XmTestLib import *
+
+def get_sedf_params(domain):
+    status, output = traceCommand("xm sched-sedf %s" %(domain.getName()))
+    return (status, output.split('\n')[1].split())
+
+
+domain = XmTestDomain(extraConfig = {"sched":"sedf"})
+
+try:
+    domain.start()
+except DomainError, e:
+    if verbose:
+        print "Failed to create test domain because:"
+        print e.extra
+    FAIL(str(e))
+
+# get current param values as baseline
+(status, params) = get_sedf_params(domain)
+
+# check rv
+if status != 0:
+    FAIL("Getting sedf parameters return non-zero rv (%d)", status)
+
+# parse out current params
+(name, domid, p, s, l, e, w) = params
+
+# if extratime is off, turn it on and drop slice to 0
+if str(e) == "0":
+    extratime = 1
+    opts = "%s -e %s" %(domain.getName(), extratime)
+    (status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+    # check rv
+    if status != 0:
+        FAIL("Failed to force extratime on (%d)" % status)
+
+    # drop slice to 0 now that we are in extratime mode
+    slice = 0
+
+    opts = "%s -s %s" %(domain.getName(), slice)
+    (status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+    # check rv
+    if status != 0:
+        FAIL("Failed to force slice to 0 (%d)" % status)
+
+
+# ASSERT(extratime=1, slice=0)
+
+# attempt to disable extratime without setting slice
+extratime = "0"
+
+opts = "%s -e %s " %(domain.getName(), extratime)
+(status, output) = traceCommand("xm sched-sedf %s" %(opts))
+
+# we should see this output from xm 
+eyecatcher = "Failed to set sedf parameters"
+
+# check for failure
+if output.find(eyecatcher) >= 0:
+    FAIL("sched-sedf let me disable extratime without a non-zero slice")
diff -r 8c1badb84c3e -r 3ea1c6118fc2 
tools/xm-test/tests/sedf/01_sedf_multi_pos.py
--- a/tools/xm-test/tests/sedf/01_sedf_multi_pos.py     Thu Mar  9 23:49:54 2006
+++ /dev/null   Fri Mar 10 00:08:59 2006
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) International Business Machines Corp., 2005
-# Author: Dan Smith <danms@xxxxxxxxxx>
-
-from XmTestLib import *
-
-sedf_opts = "20000000 5000000 0 0 0"
-
-domain = XmTestDomain(extraConfig = {"sched":"sedf"})
-
-try:
-    domain.start()
-except DomainError, e:
-    if verbose:
-        print "Failed to create test domain because:"
-        print e.extra
-    FAIL(str(e))
-
-for i in range(5):
-    status, output = traceCommand("xm sched-sedf %s %s" % (domain.getName(),
-                                                           sedf_opts))
-    if status != 0:
-        FAIL("[%i] xm sedf returned invalid %i != 0" % (i, status))
-
-    
-    
-

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.