ia64/xen-unstable
changeset 2250:613af610be8a
bitkeeper revision 1.1159.1.70 (41208580UQYjPMyX6IwpTt7euiLMgg)
Document cpu_weight config field and check value type.
Document cpu_weight config field and check value type.
author | mjw@wray-m-3.hpl.hp.com |
---|---|
date | Mon Aug 16 09:59:28 2004 +0000 (2004-08-16) |
parents | 2186fbfd11de |
children | 0cc2746cbe19 af0729973950 |
files | docs/xen_config.html tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py tools/python/xen/xm/opts.py |
line diff
1.1 --- a/docs/xen_config.html Mon Aug 16 09:38:19 2004 +0000 1.2 +++ b/docs/xen_config.html Mon Aug 16 09:59:28 2004 +0000 1.3 @@ -61,6 +61,7 @@ The top-level element, a virtual machine 1.4 <li>id: int, optional, default generated. Domain unique id. 1.5 <li>memory: int, required. Domain memory in MB. 1.6 <li>cpu: int, optional. Cpu to run on. 1.7 + <li>cpu_weight, float, optional, default 1. Cpu weight - controls share of CPU. 1.8 <li>image: linux | netbsd | ..., required. Domain image (OS-specific element). 1.9 <li>backend: any backend device type, optional, default none. 1.10 <li>device: any device type, optional, repeats. Device.
2.1 --- a/tools/python/xen/xend/XendDomainInfo.py Mon Aug 16 09:38:19 2004 +0000 2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Aug 16 09:59:28 2004 +0000 2.3 @@ -369,6 +369,7 @@ class XendDomainInfo: 2.4 self.config = None 2.5 self.id = None 2.6 self.dom = None 2.7 + self.cpu_weight = 1 2.8 self.start_time = None 2.9 self.name = None 2.10 self.memory = None 2.11 @@ -499,7 +500,10 @@ class XendDomainInfo: 2.12 try: 2.13 self.name = sxp.child_value(config, 'name') 2.14 self.check_name(self.name) 2.15 - self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1')) 2.16 + try: 2.17 + self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1')) 2.18 + except: 2.19 + raise VmError('invalid cpu weight') 2.20 if self.restore and self.dom: 2.21 xc.domain_setname(self.dom, self.name) 2.22 self.memory = int(sxp.child_value(config, 'memory'))
3.1 --- a/tools/python/xen/xm/create.py Mon Aug 16 09:38:19 2004 +0000 3.2 +++ b/tools/python/xen/xm/create.py Mon Aug 16 09:59:28 2004 +0000 3.3 @@ -101,9 +101,10 @@ gopts.var('memory', val='MEMORY', 3.4 fn=set_value, default=128, 3.5 use="Domain memory in MB.") 3.6 3.7 -gopts.var('cpu_weight', val='CPU_WEIGHT', 3.8 - fn=set_value, default=1, 3.9 - use="CPU weight.") 3.10 +gopts.var('cpu_weight', val='WEIGHT', 3.11 + fn=set_float, default=1, 3.12 + use="""Set the new domain's cpu weight. WEIGHT is a float that controls the 3.13 +domain's share of the cpu.""") 3.14 3.15 gopts.var('console', val='PORT', 3.16 fn=set_int, default=None,
4.1 --- a/tools/python/xen/xm/opts.py Mon Aug 16 09:38:19 2004 +0000 4.2 +++ b/tools/python/xen/xm/opts.py Mon Aug 16 09:59:28 2004 +0000 4.3 @@ -409,7 +409,7 @@ def set_bool(opt, k, v): 4.4 4.5 4.6 def set_value(opt, k, v): 4.7 - """Set an option to a valoue.""" 4.8 + """Set an option to a value.""" 4.9 opt.set(v) 4.10 4.11 def set_int(opt, k, v): 4.12 @@ -420,6 +420,14 @@ def set_int(opt, k, v): 4.13 opt.opts.err('Invalid value: ' + str(v)) 4.14 opt.set(v) 4.15 4.16 +def set_float(opt, k, v): 4.17 + """Set an option to a float value.""" 4.18 + try: 4.19 + v = float(v) 4.20 + except: 4.21 + opt.opts.err('Invalid value: ' + str(v)) 4.22 + opt.set(v) 4.23 + 4.24 def append_value(opt, k, v): 4.25 """Append a value to a list option.""" 4.26 opt.append(v)