aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-06 14:34:54 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-06 14:34:54 +0100
commit365e87562a84abf27bfed2bc8a9e4db3cbe0d7c8 (patch)
treef5bd0cc6a3c0234d463f1fa896a08ad9a5ff887c /tools
parent48859c62ecf1dc988eae03668852ac59bf8f147d (diff)
downloadxen-365e87562a84abf27bfed2bc8a9e4db3cbe0d7c8.tar.gz
xen-365e87562a84abf27bfed2bc8a9e4db3cbe0d7c8.tar.bz2
xen-365e87562a84abf27bfed2bc8a9e4db3cbe0d7c8.zip
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/XendDomain.py17
-rw-r--r--tools/python/xen/xm/main.py34
2 files changed, 34 insertions, 17 deletions
diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py
index f3a832509c..5820bc566c 100644
--- a/tools/python/xen/xend/XendDomain.py
+++ b/tools/python/xen/xend/XendDomain.py
@@ -1399,10 +1399,15 @@ class XendDomain:
dominfo = self.domain_lookup_nr(domid)
if not dominfo:
raise XendInvalidDomain(str(domid))
- try:
- return xc.sched_credit_domain_get(dominfo.getDomid())
- except Exception, ex:
- raise XendError(str(ex))
+
+ if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+ try:
+ return xc.sched_credit_domain_get(dominfo.getDomid())
+ except Exception, ex:
+ raise XendError(str(ex))
+ else:
+ return {'weight' : dominfo.getWeight(),
+ 'cap' : dominfo.getCap()}
def domain_sched_credit_set(self, domid, weight = None, cap = None):
"""Set credit scheduler parameters for a domain.
@@ -1436,7 +1441,9 @@ class XendDomain:
assert type(weight) == int
assert type(cap) == int
- rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
+ rc = 0
+ if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
+ rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap)
if rc == 0:
if set_weight:
dominfo.setWeight(weight)
diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index 8bc0efe90a..7f93373bd7 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -1529,7 +1529,7 @@ def xm_sched_credit(args):
doms = filter(lambda x : domid_match(domid, x),
[parse_doms_info(dom)
- for dom in getDomains(None, 'running')])
+ for dom in getDomains(None, 'all')])
if weight is None and cap is None:
if domid is not None and doms == []:
@@ -1545,7 +1545,7 @@ def xm_sched_credit(args):
server.xenapi.VM.get_metrics(
get_single_vm(d['name'])))
else:
- info = server.xend.domain.sched_credit_get(d['domid'])
+ info = server.xend.domain.sched_credit_get(d['name'])
except xmlrpclib.Fault:
pass
@@ -1557,8 +1557,8 @@ def xm_sched_credit(args):
info['cap'] = int(info['cap'])
info['name'] = d['name']
- info['domid'] = int(d['domid'])
- print( ("%(name)-32s %(domid)5d %(weight)6d %(cap)4d") % info)
+ info['domid'] = str(d['domid'])
+ print( ("%(name)-32s %(domid)5s %(weight)6d %(cap)4d") % info)
else:
if domid is None:
# place holder for system-wide scheduler parameters
@@ -1566,14 +1566,24 @@ def xm_sched_credit(args):
usage('sched-credit')
if serverType == SERVER_XEN_API:
- server.xenapi.VM.add_to_VCPUs_params_live(
- get_single_vm(domid),
- "weight",
- weight)
- server.xenapi.VM.add_to_VCPUs_params_live(
- get_single_vm(domid),
- "cap",
- cap)
+ if doms[0]['domid']:
+ server.xenapi.VM.add_to_VCPUs_params_live(
+ get_single_vm(domid),
+ "weight",
+ weight)
+ server.xenapi.VM.add_to_VCPUs_params_live(
+ get_single_vm(domid),
+ "cap",
+ cap)
+ else:
+ server.xenapi.VM.add_to_VCPUs_params(
+ get_single_vm(domid),
+ "weight",
+ weight)
+ server.xenapi.VM.add_to_VCPUs_params(
+ get_single_vm(domid),
+ "cap",
+ cap)
else:
result = server.xend.domain.sched_credit_set(domid, weight, cap)
if result != 0: