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>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-07-06 14:34:54 +01:00
1 parent 48859c62ec
commit 365e87562a
2 files changed
+34 -17

No files matched your search

+12 -5
View File
@@ -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)
+22 -12
View File
@@ -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:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.