diff -r f5121d001d1a tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Sat Dec 09 16:29:52 2006 +0000 +++ b/tools/python/xen/xend/XendDomainInfo.py Tue Dec 12 14:06:25 2006 -0500 @@ -896,6 +896,10 @@ class XendDomainInfo: """Get this domain's target memory size, in KB.""" return self.info['memory_static_min'] * 1024 + def getMemoryMaximum(self): + """Get this domain's maximum memory size, in KB.""" + return self.info['memory_static_max'] * 1024 + def getResume(self): return str(self._resume) @@ -1363,9 +1367,9 @@ class XendDomainInfo: # Use architecture- and image-specific calculations to determine # the various headrooms necessary, given the raw configured # values. maxmem, memory, and shadow are all in KiB. + memory = self.image.getRequiredAvailableMemory( + self.info['memory_static_min'] * 1024) maxmem = self.image.getRequiredAvailableMemory( - self.info['memory_static_min'] * 1024) - memory = self.image.getRequiredAvailableMemory( self.info['memory_static_max'] * 1024) shadow = self.image.getRequiredShadowMemory( self.info['shadow_memory'] * 1024, diff -r f5121d001d1a tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Sat Dec 09 16:29:52 2006 +0000 +++ b/tools/python/xen/xend/image.py Mon Dec 11 16:37:12 2006 -0500 @@ -144,6 +144,14 @@ class ImageHandler: architecture- or image-specific code may override this to add headroom where necessary.""" return self.getRequiredAvailableMemory(self.vm.getMemoryTarget()) + + def getRequiredMaximumReservation(self): + """@param mem_kb The maximum possible memory, in KiB. + @return The corresponding required amount of memory to be free, also + in KiB. This is normally the same as getRequiredAvailableMemory, but + architecture- or image-specific code may override this to + add headroom where necessary.""" + return self.getRequiredAvailableMemory(self.vm.getMemoryMaximum()) def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb): """@param shadow_mem_kb The configured shadow memory, in KiB. @@ -539,6 +547,9 @@ class X86_HVM_ImageHandler(HVMImageHandl def getRequiredInitialReservation(self): return self.vm.getMemoryTarget() + def getRequiredMaximumReservation(self): + return self.vm.getMemoryMaximum() + def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb): # 256 pages (1MB) per vcpu, # plus 1 page per MiB of RAM for the P2M map, @@ -553,7 +564,7 @@ class X86_Linux_ImageHandler(LinuxImageH def buildDomain(self): # set physical mapping limit # add an 8MB slack to balance backend allocations. - mem_kb = self.getRequiredInitialReservation() + (8 * 1024) + mem_kb = self.getRequiredMaximumReservation() + (8 * 1024) xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) return LinuxImageHandler.buildDomain(self)