# HG changeset patch
# User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
# Node ID 3b7c45e3bf941c0e0f4b727740a0785a4c60ddbc
# Parent 39aaa54756dbc4723ae6e467404de2c3af6513e5
This patch adds value checking of sched-credit xm options.
Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
tools/python/xen/xend/XendDomain.py | 12 +++++++++++-
tools/python/xen/xm/main.py | 5 -----
2 files changed, 11 insertions(+), 6 deletions(-)
diff -r 39aaa54756db -r 3b7c45e3bf94 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Thu Sep 21 13:53:49 2006 +0100
+++ b/tools/python/xen/xend/XendDomain.py Thu Sep 21 14:10:56 2006 +0100
@@ -560,13 +560,23 @@ class XendDomain:
except Exception, ex:
raise XendError(str(ex))
- def domain_sched_credit_set(self, domid, weight, cap):
+ def domain_sched_credit_set(self, domid, weight = None, cap = None):
"""Set credit scheduler parameters for a domain.
"""
dominfo = self.domain_lookup_by_name_or_id_nr(domid)
if not dominfo:
raise XendInvalidDomain(str(domid))
try:
+ if weight is None:
+ weight = int(0)
+ elif weight < 1 or weight > 65535:
+ raise XendError("weight is out of range")
+
+ if cap is None:
+ cap = int(~0)
+ elif cap < 0 or cap > dominfo.getVCpuCount() * 100:
+ raise XendError("cap is out of range")
+
return xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
except Exception, ex:
raise XendError(str(ex))
diff -r 39aaa54756db -r 3b7c45e3bf94 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Sep 21 13:53:49 2006 +0100
+++ b/tools/python/xen/xm/main.py Thu Sep 21 14:10:56 2006 +0100
@@ -822,11 +822,6 @@ def xm_sched_credit(args):
if weight is None and cap is None:
print server.xend.domain.sched_credit_get(domain)
else:
- if weight is None:
- weight = int(0)
- if cap is None:
- cap = int(~0)
-
err = server.xend.domain.sched_credit_set(domain, weight, cap)
if err != 0:
print err
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|