ia64/xen-unstable

changeset 11559:3b7c45e3bf94

This patch adds value checking of sched-credit xm options.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Thu Sep 21 14:10:56 2006 +0100 (2006-09-21)
parents 39aaa54756db
children 5bc0e9a50687
files tools/python/xen/xend/XendDomain.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Sep 21 13:53:49 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Sep 21 14:10:56 2006 +0100
     1.3 @@ -560,13 +560,23 @@ class XendDomain:
     1.4          except Exception, ex:
     1.5              raise XendError(str(ex))
     1.6      
     1.7 -    def domain_sched_credit_set(self, domid, weight, cap):
     1.8 +    def domain_sched_credit_set(self, domid, weight = None, cap = None):
     1.9          """Set credit scheduler parameters for a domain.
    1.10          """
    1.11          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.12          if not dominfo:
    1.13              raise XendInvalidDomain(str(domid))
    1.14          try:
    1.15 +            if weight is None:
    1.16 +                weight = int(0)
    1.17 +            elif weight < 1 or weight > 65535:
    1.18 +                raise XendError("weight is out of range")
    1.19 +
    1.20 +            if cap is None:
    1.21 +                cap = int(~0)
    1.22 +            elif cap < 0 or cap > dominfo.getVCpuCount() * 100:
    1.23 +                raise XendError("cap is out of range")
    1.24 +
    1.25              return xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
    1.26          except Exception, ex:
    1.27              raise XendError(str(ex))
     2.1 --- a/tools/python/xen/xm/main.py	Thu Sep 21 13:53:49 2006 +0100
     2.2 +++ b/tools/python/xen/xm/main.py	Thu Sep 21 14:10:56 2006 +0100
     2.3 @@ -822,11 +822,6 @@ def xm_sched_credit(args):
     2.4      if weight is None and cap is None:
     2.5          print server.xend.domain.sched_credit_get(domain)
     2.6      else:
     2.7 -        if weight is None:
     2.8 -            weight = int(0)
     2.9 -        if cap is None:
    2.10 -            cap = int(~0)
    2.11 -
    2.12          err = server.xend.domain.sched_credit_set(domain, weight, cap)
    2.13          if err != 0:
    2.14              print err