WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Sanity check changes to memory dynamic/st

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Sanity check changes to memory dynamic/static min/max and ensure we cannot
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 27 Apr 2007 10:20:15 -0700
Delivery-date: Fri, 27 Apr 2007 10:19:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Sanity check changes to memory dynamic/static min/max and ensure we cannot, Xen patchbot-unstable <=