direct-io.hg

changeset 15472:d6078c942355

Improve xm sched-credit command for inactive managed domains
Allows to change the scheduler parameters of inactive managed domains.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Fri Jul 06 14:34:54 2007 +0100 (2007-07-06)
parents 7ac7f1472414
children 300d1effb792
files tools/python/xen/xend/XendDomain.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Jul 06 14:22:59 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Jul 06 14:34:54 2007 +0100
     1.3 @@ -1399,10 +1399,15 @@ class XendDomain:
     1.4          dominfo = self.domain_lookup_nr(domid)
     1.5          if not dominfo:
     1.6              raise XendInvalidDomain(str(domid))
     1.7 -        try:
     1.8 -            return xc.sched_credit_domain_get(dominfo.getDomid())
     1.9 -        except Exception, ex:
    1.10 -            raise XendError(str(ex))
    1.11 +        
    1.12 +        if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
    1.13 +            try:
    1.14 +                return xc.sched_credit_domain_get(dominfo.getDomid())
    1.15 +            except Exception, ex:
    1.16 +                raise XendError(str(ex))
    1.17 +        else:
    1.18 +            return {'weight' : dominfo.getWeight(),
    1.19 +                    'cap'    : dominfo.getCap()} 
    1.20      
    1.21      def domain_sched_credit_set(self, domid, weight = None, cap = None):
    1.22          """Set credit scheduler parameters for a domain.
    1.23 @@ -1436,7 +1441,9 @@ class XendDomain:
    1.24              assert type(weight) == int
    1.25              assert type(cap) == int
    1.26  
    1.27 -            rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
    1.28 +            rc = 0
    1.29 +            if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
    1.30 +                rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
    1.31              if rc == 0:
    1.32                  if set_weight:
    1.33                      dominfo.setWeight(weight)
     2.1 --- a/tools/python/xen/xm/main.py	Fri Jul 06 14:22:59 2007 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Fri Jul 06 14:34:54 2007 +0100
     2.3 @@ -1529,7 +1529,7 @@ def xm_sched_credit(args):
     2.4  
     2.5      doms = filter(lambda x : domid_match(domid, x),
     2.6                    [parse_doms_info(dom)
     2.7 -                  for dom in getDomains(None, 'running')])
     2.8 +                  for dom in getDomains(None, 'all')])
     2.9  
    2.10      if weight is None and cap is None:
    2.11          if domid is not None and doms == []: 
    2.12 @@ -1545,7 +1545,7 @@ def xm_sched_credit(args):
    2.13                          server.xenapi.VM.get_metrics(
    2.14                              get_single_vm(d['name'])))
    2.15                  else:
    2.16 -                    info = server.xend.domain.sched_credit_get(d['domid'])
    2.17 +                    info = server.xend.domain.sched_credit_get(d['name'])
    2.18              except xmlrpclib.Fault:
    2.19                  pass
    2.20  
    2.21 @@ -1557,8 +1557,8 @@ def xm_sched_credit(args):
    2.22              info['cap']    = int(info['cap'])
    2.23              
    2.24              info['name']  = d['name']
    2.25 -            info['domid'] = int(d['domid'])
    2.26 -            print( ("%(name)-32s %(domid)5d %(weight)6d %(cap)4d") % info)
    2.27 +            info['domid'] = str(d['domid'])
    2.28 +            print( ("%(name)-32s %(domid)5s %(weight)6d %(cap)4d") % info)
    2.29      else:
    2.30          if domid is None:
    2.31              # place holder for system-wide scheduler parameters
    2.32 @@ -1566,14 +1566,24 @@ def xm_sched_credit(args):
    2.33              usage('sched-credit')
    2.34  
    2.35          if serverType == SERVER_XEN_API:
    2.36 -            server.xenapi.VM.add_to_VCPUs_params_live(
    2.37 -                get_single_vm(domid),
    2.38 -                "weight",
    2.39 -                weight)
    2.40 -            server.xenapi.VM.add_to_VCPUs_params_live(
    2.41 -                get_single_vm(domid),
    2.42 -                "cap",
    2.43 -                cap)            
    2.44 +            if doms[0]['domid']:
    2.45 +                server.xenapi.VM.add_to_VCPUs_params_live(
    2.46 +                    get_single_vm(domid),
    2.47 +                    "weight",
    2.48 +                    weight)
    2.49 +                server.xenapi.VM.add_to_VCPUs_params_live(
    2.50 +                    get_single_vm(domid),
    2.51 +                    "cap",
    2.52 +                    cap)
    2.53 +            else:
    2.54 +                server.xenapi.VM.add_to_VCPUs_params(
    2.55 +                    get_single_vm(domid),
    2.56 +                    "weight",
    2.57 +                    weight)
    2.58 +                server.xenapi.VM.add_to_VCPUs_params(
    2.59 +                    get_single_vm(domid),
    2.60 +                    "cap",
    2.61 +                    cap)
    2.62          else:
    2.63              result = server.xend.domain.sched_credit_set(domid, weight, cap)
    2.64              if result != 0: