ia64/xen-unstable
changeset 13061:bc3ff220d24d
Fix mem-set, mem-max, and vcpu-set commands when used against inactive domains.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Fri Dec 15 11:50:04 2006 +0000 (2006-12-15) |
parents | 779e99f810ca |
children | c6f637694b85 |
files | tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDomain.py |
line diff
1.1 --- a/tools/python/xen/xend/XendDomain.py Fri Dec 15 11:48:40 2006 +0000 1.2 +++ b/tools/python/xen/xend/XendDomain.py Fri Dec 15 11:50:04 2006 +0000 1.3 @@ -1339,11 +1339,7 @@ class XendDomain: 1.4 dominfo = self.domain_lookup_nr(domid) 1.5 if not dominfo: 1.6 raise XendInvalidDomain(str(domid)) 1.7 - maxmem = int(mem) * 1024 1.8 - try: 1.9 - return xc.domain_setmaxmem(dominfo.getDomid(), maxmem) 1.10 - except Exception, ex: 1.11 - raise XendError(str(ex)) 1.12 + dominfo.setMemoryMaximum(mem) 1.13 1.14 def domain_ioport_range_enable(self, domid, first, last): 1.15 """Enable access to a range of IO ports for a domain
2.1 --- a/tools/python/xen/xend/XendDomainInfo.py Fri Dec 15 11:48:40 2006 +0000 2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Dec 15 11:50:04 2006 +0000 2.3 @@ -551,8 +551,34 @@ class XendDomainInfo: 2.4 raise XendError('Invalid memory size') 2.5 2.6 self.info['memory_static_min'] = target 2.7 - self.storeVm("memory", target) 2.8 - self.storeDom("memory/target", target << 10) 2.9 + if self.domid >= 0: 2.10 + self.storeVm("memory", target) 2.11 + self.storeDom("memory/target", target << 10) 2.12 + else: 2.13 + self.info['memory_dynamic_min'] = target 2.14 + xen.xend.XendDomain.instance().managed_config_save(self) 2.15 + 2.16 + def setMemoryMaximum(self, limit): 2.17 + """Set the maximum memory limit of this domain 2.18 + @param limit: In MiB. 2.19 + """ 2.20 + log.debug("Setting memory maximum of domain %s (%d) to %d MiB.", 2.21 + self.info['name_label'], self.domid, limit) 2.22 + 2.23 + if limit <= 0: 2.24 + raise XendError('Invalid memory size') 2.25 + 2.26 + self.info['memory_static_max'] = limit 2.27 + if self.domid >= 0: 2.28 + maxmem = int(limit) * 1024 2.29 + try: 2.30 + return xc.domain_setmaxmem(self.domid, maxmem) 2.31 + except Exception, ex: 2.32 + raise XendError(str(ex)) 2.33 + else: 2.34 + self.info['memory_dynamic_max'] = limit 2.35 + xen.xend.XendDomain.instance().managed_config_save(self) 2.36 + 2.37 2.38 def getVCPUInfo(self): 2.39 try: 2.40 @@ -831,18 +857,23 @@ class XendDomainInfo: 2.41 2.42 def setVCpuCount(self, vcpus): 2.43 self.info['vcpu_avail'] = (1 << vcpus) - 1 2.44 - self.storeVm('vcpu_avail', self.info['vcpu_avail']) 2.45 - # update dom differently depending on whether we are adjusting 2.46 - # vcpu number up or down, otherwise _vcpuDomDetails does not 2.47 - # disable the vcpus 2.48 - if self.info['vcpus_number'] > vcpus: 2.49 - # decreasing 2.50 - self._writeDom(self._vcpuDomDetails()) 2.51 + if self.domid >= 0: 2.52 + self.storeVm('vcpu_avail', self.info['vcpu_avail']) 2.53 + # update dom differently depending on whether we are adjusting 2.54 + # vcpu number up or down, otherwise _vcpuDomDetails does not 2.55 + # disable the vcpus 2.56 + if self.info['vcpus_number'] > vcpus: 2.57 + # decreasing 2.58 + self._writeDom(self._vcpuDomDetails()) 2.59 + self.info['vcpus_number'] = vcpus 2.60 + else: 2.61 + # same or increasing 2.62 + self.info['vcpus_number'] = vcpus 2.63 + self._writeDom(self._vcpuDomDetails()) 2.64 + else: 2.65 self.info['vcpus_number'] = vcpus 2.66 - else: 2.67 - # same or increasing 2.68 - self.info['vcpus_number'] = vcpus 2.69 - self._writeDom(self._vcpuDomDetails()) 2.70 + self.info['online_vcpus'] = vcpus 2.71 + xen.xend.XendDomain.instance().managed_config_save(self) 2.72 2.73 def getLabel(self): 2.74 return security.get_security_info(self.info, 'label')
3.1 --- a/tools/python/xen/xend/server/SrvDomain.py Fri Dec 15 11:48:40 2006 +0000 3.2 +++ b/tools/python/xen/xend/server/SrvDomain.py Fri Dec 15 11:50:04 2006 +0000 3.3 @@ -160,12 +160,9 @@ class SrvDomain(SrvDir): 3.4 return val 3.5 3.6 def op_maxmem_set(self, _, req): 3.7 - fn = FormFn(self.xd.domain_maxmem_set, 3.8 - [['dom', 'int'], 3.9 - ['memory', 'int']]) 3.10 - val = fn(req.args, {'dom': self.dom.domid}) 3.11 - return val 3.12 - 3.13 + return self.call(self.dom.setMemoryMaximum, 3.14 + [['memory', 'int']], 3.15 + req) 3.16 3.17 def call(self, fn, args, req): 3.18 return FormFn(fn, args)(req.args)