WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] - Reworked to use your match_domid suggestion and filter

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] - Reworked to use your match_domid suggestion and filtering
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 11 Mar 2006 11:56:11 +0000
Delivery-date: Sat, 11 Mar 2006 11:57:37 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID ed1afb12106e0047ba66b0ebd0779c2da27928cf
# Parent  90bac1d23a0c1c8e4105793a5b2aa76d2468bd89
- 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@xxxxxxxxxx>

diff -r 90bac1d23a0c -r ed1afb12106e tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Sat Mar 11 10:20:32 2006
+++ b/tools/python/xen/xm/main.py       Sat Mar 11 10:45:10 2006
@@ -84,10 +84,11 @@
 sched_bvt_ctxallow_help = """sched-bvt-ctxallow <Allow>       Set the BVT 
scheduler context switch
                                     allowance"""
 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\
+"              -p, --period          Relative deadline(ms).\n\
+              -s, --slice           Worst-case execution time(ms)\n\
+                                    (slice < period).\n\
+              -l, --latency         scaled period(ms) in case the domain\n\
+                                    is doing 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\
@@ -641,26 +642,25 @@
     server.xend_node_cpu_bvt_slice_set(slice)
 
 def xm_sched_sedf(args):
+    def ns_to_ms(val):
+        return float(val) * 0.000001
+    
+    def ms_to_ns(val):
+        return (float(val) / 0.000001)
+
     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.
+        info['period']  = ns_to_ms(info['period'])
+        info['slice']   = ns_to_ms(info['slice'])
+        info['latency'] = ns_to_ms(info['latency'])
+        print( ("%(name)-32s %(dom)3d %(period)9.1f %(slice)9.1f" +
+                " %(latency)7.1f %(extratime)6d %(weight)6d") % info)
+
     def domid_match(domid, info):
-        d = ""
-        f = ""
-        try:
-            d = int(domid)
-            f = 'dom'
-        except:
-            d = domid 
-            f = 'name'
-
-        return (d == info[f])
-          
+        return domid is None or domid == info['name'] or domid == 
str(info['dom'])
+
     # we want to just display current info if no parameters are passed
     if len(args) == 0:
-        domid = '-1'
+        domid = None
     else:
         # we expect at least a domain id (name or number)
         # and at most a domid up to 5 options with values
@@ -677,13 +677,14 @@
         err(opterr)
         sys.exit(1)
     
+    # convert to nanoseconds if needed 
     for (k, v) in options:
         if k in ['-p', '--period']:
-            opts['period'] = v
+            opts['period'] = ms_to_ns(v)
         elif k in ['-s', '--slice']:
-            opts['slice'] = v
+            opts['slice'] = ms_to_ns(v)
         elif k in ['-l', '--latency']:
-            opts['latency'] = v
+            opts['latency'] = ms_to_ns(v)
         elif k in ['-e', '--extratime']:
             opts['extratime'] = v
         elif k in ['-w', '--weight']:
@@ -691,37 +692,35 @@
 
     # 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)
+        print '%-33s %-2s %-4s %-4s %-7s %-5s %-6s'%('Name','ID','Period(ms)',
+                                                     'Slice(ms)', 'Lat(ms)',
+                                                     'Extra','Weight')
+
+    from xen.xend.XendClient import server
+    doms = filter(lambda x : domid_match(domid, x),
+                        [parse_doms_info(dom) for dom in getDomains("")])
+    for d in doms:
+        # 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, converting user input
+            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):
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py
--- a/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py      Sat Mar 11 
10:20:32 2006
+++ b/tools/xm-test/tests/sedf/01_sedf_period_slice_pos.py      Sat Mar 11 
10:45:10 2006
@@ -33,8 +33,8 @@
 
 # NB: setting period requires non-zero slice 
 # scale current period in half
-period = str(int(p) / 2)
-slice  = str(int(p) / 4)
+period = str(float(p) / 2)
+slice  = str(float(p) / 4)
 
 opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
 (status, output) = traceCommand("xm sched-sedf %s" %(opts))
@@ -53,10 +53,10 @@
 (name,domid,p1,s1,l1,e1,w1) = params
 
 if p1 != period:
-    FAIL("Failed to change domain period from %d to %d" %(p, period))
+    FAIL("Failed to change domain period from %f to %f" %(p, period))
 
 if s1 != slice:
-    FAIL("Failed to change domain slice from %d to %d" %(s, slice))
+    FAIL("Failed to change domain slice from %f to %f" %(s, slice))
 
 # Stop the domain (nice shutdown)
 domain.stop()
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py
--- a/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py      Sat Mar 11 
10:20:32 2006
+++ b/tools/xm-test/tests/sedf/02_sedf_period_lower_neg.py      Sat Mar 11 
10:45:10 2006
@@ -28,7 +28,7 @@
 
 # NB: setting period requires non-zero slice 
 # scale current period in half
-slice  = "1"
+slice  = "5"
 
 opts = "%s -p %s -s %s" %(domain.getName(), period, slice)
 (status, output) = traceCommand("xm sched-sedf %s" %(opts))
@@ -39,3 +39,6 @@
 # check for failure
 if output.find(eyecatcher) >= 0:
     FAIL("sched-sedf let me set bogus period (%s)" %(period))
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py
--- a/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py       Sat Mar 11 
10:20:32 2006
+++ b/tools/xm-test/tests/sedf/03_sedf_slice_lower_neg.py       Sat Mar 11 
10:45:10 2006
@@ -34,4 +34,7 @@
 
 # check for failure
 if output.find(eyecatcher) >= 0:
-    FAIL("sched-sedf let me set bogus slice (%s)" %(slice)
+    FAIL("sched-sedf let me set bogus slice (%s)" %(slice))
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py
--- a/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py       Sat Mar 11 
10:20:32 2006
+++ b/tools/xm-test/tests/sedf/04_sedf_slice_upper_neg.py       Sat Mar 11 
10:45:10 2006
@@ -32,7 +32,7 @@
 (name, domid, p, s, l, e, w) = params
 
 # set slice > than current period
-slice  = str(int(p)+1)
+slice  = str(float(p)+1)
 
 opts = "%s -s %s" %(domain.getName(), slice)
 (status, output) = traceCommand("xm sched-sedf %s" %(opts))
@@ -43,3 +43,6 @@
 # check for failure
 if output.find(eyecatcher) >= 0:
     FAIL("sched-sedf let me set a slice bigger than my period.")
+
+# Stop the domain (nice shutdown)
+domain.stop()
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/05_sedf_extratime_pos.py
--- a/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Sat Mar 11 10:20:32 2006
+++ b/tools/xm-test/tests/sedf/05_sedf_extratime_pos.py Sat Mar 11 10:45:10 2006
@@ -38,7 +38,7 @@
 # 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 ) )
+    opts += " -s %s" %( str( (float(p)/2)+1 ) )
     direction = "enable"
     
 (status, output) = traceCommand("xm sched-sedf %s" %(opts))
diff -r 90bac1d23a0c -r ed1afb12106e 
tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py
--- a/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Sat Mar 11 
10:20:32 2006
+++ b/tools/xm-test/tests/sedf/06_sedf_extratime_disable_neg.py Sat Mar 11 
10:45:10 2006
@@ -66,3 +66,6 @@
 # check for failure
 if output.find(eyecatcher) >= 0:
     FAIL("sched-sedf let me disable extratime without a non-zero slice")
+
+# Stop the domain (nice shutdown)
+domain.stop()

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] - Reworked to use your match_domid suggestion and filtering, Xen patchbot -unstable <=