[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Sanity check changes to memory dynamic/static min/max and ensure we cannot
# HG changeset patch # User Steven Hand <steven@xxxxxxxxxxxxx> # Date 1177679782 -3600 # Node ID 2c90965d08106b4b8394de498cf2295dd08d81a7 # Parent 3c352bbc894dad767255a3103bf9d81594354736 Sanity check changes to memory dynamic/static min/max and ensure we cannot get ourselves into an inconsistent state. Signed-off-by: Steven Hand <steven@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendDomainInfo.py | 25 ++++++++++++++++--------- 1 files changed, 16 insertions(+), 9 deletions(-) diff -r 3c352bbc894d -r 2c90965d0810 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Fri Apr 27 13:31:09 2007 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Apr 27 14:16:22 2007 +0100 @@ -580,12 +580,9 @@ class XendDomainInfo: log.debug("Setting memory target of domain %s (%s) to %d MiB.", self.info['name_label'], str(self.domid), target) - if target <= 0: - raise XendError('Invalid memory size') - MiB = 1024 * 1024 - self.info['memory_dynamic_min'] = target * MiB - self.info['memory_dynamic_max'] = target * MiB + self._safe_set_memory('memory_dynamic_min', target * MiB) + self._safe_set_memory('memory_dynamic_max', target * MiB) if self.domid >= 0: self.storeVm("memory", target) @@ -2134,14 +2131,24 @@ class XendDomainInfo: def get_memory_dynamic_min(self): return self.info.get('memory_dynamic_min', 0) + # only update memory-related config values if they maintain sanity + def _safe_set_memory(self, key, newval): + oldval = self.info.get(key, 0) + try: + self.info[key] = newval + self.info._memory_sanity_check() + except Exception, ex: + self.info[key] = oldval + raise + def set_memory_static_max(self, val): - self.info['memory_static_max'] = val + self._safe_set_memory('memory_static_max', val) def set_memory_static_min(self, val): - self.info['memory_static_min'] = val + self._safe_set_memory('memory_static_min', val) def set_memory_dynamic_max(self, val): - self.info['memory_dynamic_max'] = val + self._safe_set_memory('memory_dynamic_max', val) def set_memory_dynamic_min(self, val): - self.info['memory_dynamic_min'] = val + self._safe_set_memory('memory_dynamic_min', val) def get_vcpus_params(self): if self.getDomid() is None: _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |