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

[Xen-changelog] [xen-unstable] [TOOLS] Improve information displayed by the xm sched-credit command.



# HG changeset patch
# User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
# Date 1168082272 0
# Node ID 69579f9f1c8197a432ebf8f59aca14db9eac70ad
# Parent  9865145e53eb02ddc2e2792f80bb7d54bc754a65
[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@xxxxxxxxxxxxxx>
---
 tools/python/xen/xm/main.py |   44 ++++++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 14 deletions(-)

diff -r 9865145e53eb -r 69579f9f1c81 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri Jan 05 18:17:36 2007 +0000
+++ b/tools/python/xen/xm/main.py       Sat Jan 06 11:17:52 2007 +0000
@@ -130,7 +130,7 @@ SUBCOMMAND_HELP = {
     'log'         : ('', 'Print Xend log'),
     'rename'      : ('<Domain> <NewDomainName>', 'Rename a domain.'),
     'sched-sedf'  : ('<Domain> [options]', 'Get/set EDF parameters.'),
-    'sched-credit': ('-d <Domain> [-w[=WEIGHT]|-c[=CAP]]',
+    'sched-credit': ('[-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]',
                      'Get/set credit scheduler parameters.'),
     'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
     'vcpu-list'   : ('[<Domain>]',
@@ -717,6 +717,10 @@ def parse_sedf_info(info):
         'weight'   : get_info('weight',        int,   -1),
         }
 
+def domid_match(domid, info):
+    return domid is None or domid == info['name'] or \
+           domid == str(info['domid'])
+
 def xm_brief_list(doms):
     print '%-40s %3s %5s %5s %10s %9s' % \
           ('Name', 'ID', 'Mem', 'VCPUs', 'State', 'Time(s)')
@@ -1091,10 +1095,6 @@ def xm_sched_sedf(args):
         print( ("%(name)-32s %(domid)3d %(period)9.1f %(slice)9.1f" +
                 " %(latency)7.1f %(extratime)6d %(weight)6d") % info)
 
-    def domid_match(domid, info):
-        return domid is None or domid == info['name'] or \
-               domid == str(info['domid'])
-
     # we want to just display current info if no parameters are passed
     if len(args) == 0:
         domid = None
@@ -1174,27 +1174,43 @@ def xm_sched_credit(args):
         err(opterr)
         usage('sched-credit')
 
-    domain = None
+    domid = None
     weight = None
     cap = None
 
     for o, a in opts:
         if o == "-d":
-            domain = a
+            domid = a
         elif o == "-w":
             weight = int(a)
         elif o == "-c":
             cap = int(a);
 
-    if domain is None:
-        # place holder for system-wide scheduler parameters
-        err("No domain given.")
-        usage('sched-credit')
+    doms = filter(lambda x : domid_match(domid, x),
+                  [parse_doms_info(dom)
+                  for dom in getDomains(None, 'running')])
 
     if weight is None and cap is None:
-        print server.xend.domain.sched_credit_get(domain)
-    else:
-        result = server.xend.domain.sched_credit_set(domain, weight, cap)
+        # print header if we aren't setting any parameters
+        print '%-33s %-2s %-6s %-4s' % ('Name','ID','Weight','Cap')
+        
+        for d in doms:
+            try:
+                info = server.xend.domain.sched_credit_get(d['domid'])
+            except xmlrpclib.Fault:
+                # domain does not support sched-credit?
+                info = {'weight': -1, 'cap': -1}
+            
+            info['name']  = d['name']
+            info['domid'] = int(d['domid'])
+            print( ("%(name)-32s %(domid)3d %(weight)6d %(cap)4d") % info)
+    else:
+        if domid is None:
+            # place holder for system-wide scheduler parameters
+            err("No domain given.")
+            usage('sched-credit')
+        
+        result = server.xend.domain.sched_credit_set(domid, weight, cap)
         if result != 0:
             err(str(result))
 

_______________________________________________
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®.