mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1159.1.70 (41208580UQYjPMyX6IwpTt7euiLMgg)
Document cpu_weight config field and check value type.
This commit is contained in:
1 parent
84c35a15ae
commit
9589427638
4 files changed
+19
-5
No files matched your search
@@ -369,6 +369,7 @@ class XendDomainInfo:
|
||||
self.config = None
|
||||
self.id = None
|
||||
self.dom = None
|
||||
self.cpu_weight = 1
|
||||
self.start_time = None
|
||||
self.name = None
|
||||
self.memory = None
|
||||
@@ -499,7 +500,10 @@ class XendDomainInfo:
|
||||
try:
|
||||
self.name = sxp.child_value(config, 'name')
|
||||
self.check_name(self.name)
|
||||
self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1'))
|
||||
try:
|
||||
self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1'))
|
||||
except:
|
||||
raise VmError('invalid cpu weight')
|
||||
if self.restore and self.dom:
|
||||
xc.domain_setname(self.dom, self.name)
|
||||
self.memory = int(sxp.child_value(config, 'memory'))
|
||||
|
||||
@@ -101,9 +101,10 @@ gopts.var('memory', val='MEMORY',
|
||||
fn=set_value, default=128,
|
||||
use="Domain memory in MB.")
|
||||
|
||||
gopts.var('cpu_weight', val='CPU_WEIGHT',
|
||||
fn=set_value, default=1,
|
||||
use="CPU weight.")
|
||||
gopts.var('cpu_weight', val='WEIGHT',
|
||||
fn=set_float, default=1,
|
||||
use="""Set the new domain's cpu weight. WEIGHT is a float that controls the
|
||||
domain's share of the cpu.""")
|
||||
|
||||
gopts.var('console', val='PORT',
|
||||
fn=set_int, default=None,
|
||||
|
||||
@@ -409,7 +409,7 @@ def set_bool(opt, k, v):
|
||||
|
||||
|
||||
def set_value(opt, k, v):
|
||||
"""Set an option to a valoue."""
|
||||
"""Set an option to a value."""
|
||||
opt.set(v)
|
||||
|
||||
def set_int(opt, k, v):
|
||||
@@ -420,6 +420,14 @@ def set_int(opt, k, v):
|
||||
opt.opts.err('Invalid value: ' + str(v))
|
||||
opt.set(v)
|
||||
|
||||
def set_float(opt, k, v):
|
||||
"""Set an option to a float value."""
|
||||
try:
|
||||
v = float(v)
|
||||
except:
|
||||
opt.opts.err('Invalid value: ' + str(v))
|
||||
opt.set(v)
|
||||
|
||||
def append_value(opt, k, v):
|
||||
"""Append a value to a list option."""
|
||||
opt.append(v)
|
||||
|
||||