[XenPPC] [PATCH] [XEND] abstract architecture-specific bits in image.py
Since this patch wasn't committed, the shadow2 changes created conflicts. Here is the respin. Note that I have not tested with shadow2, but as you can see below the math doesn't need to be so complicated. Ewan, please apply or comment. [XEND] abstract architecture-specific bits in image.py - create arch.type (which evaluates to "x86", "ia64" or "powerpc") - create subclasses for x86 and ia64 HVM loaders - rework findImageHandlerClass() Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> diff -r 5fc1fe790835 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Sat Aug 19 17:07:54 2006 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Tue Aug 22 16:11:57 2006 -0500 @@ -30,7 +30,6 @@ import time import time import threading import os -import math import xen.lowlevel.xc from xen.util import asserts @@ -1280,34 +1279,27 @@ class XendDomainInfo: for v in range(0, self.info['max_vcpu_id']+1): xc.vcpu_setaffinity(self.domid, v, self.info['cpus']) -# set domain maxmem in KiB -xc.domain_setmaxmem(self.domid, self.info['maxmem'] * 1024) - -m = self.image.getDomainMemory(self.info['memory'] * 1024) +# set memory limit +maxmem = self.image.getRequiredMemory(self.info['maxmem'] * 1024) +xc.domain_setmaxmem(self.domid, maxmem) + +mem_kb = self.image.getRequiredMemory(self.info['memory'] * 1024) # get the domain's shadow memory requirement -sm = int(math.ceil(self.image.getDomainShadowMemory(m) / 1024.0)) -if self.info['shadow_memory'] > sm: -sm = self.info['shadow_memory'] +shadow_kb = self.image.getRequiredShadowMemory(mem_kb) +shadow_kb_req = self.info['shadow_memory'] * 1024 +if shadow_kb_req > shadow_kb: +shadow_kb = shadow_kb_req # Make sure there's enough RAM available for the domain -balloon.free(m + sm * 1024) +balloon.free(mem_kb + shadow_kb) # Set up the shadow memory -sm = xc.shadow_mem_control(self.domid, mb=sm) -self.info['shadow_memory'] = sm - -init_reservation = self.info['memory'] * 1024 -if os.uname()[4] in ('ia64', 'ppc64'): -# Workaround for architectures that don't yet support -# ballooning. -init_reservation = m -# Following line from [EMAIL PROTECTED] -# Needed for IA64 until supports ballooning -- okay for PPC64? -xc.domain_setmaxmem(self.domid, m) - -xc.domain_memory_increase_reservation(self.domid, init_reservation, - 0, 0) +shadow_cur = xc.shadow_mem_control(self.domid, shadow_kb * 1024) +self.info['shadow_memory'] = shadow_cur + +# initial memory allocation +xc.domain_memory_increase_reservation(self.domid, mem_kb, 0, 0) self.createChannels() diff -r 5fc1fe790835 tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.pySat Aug 19 17:07:54 2006 +0100 +++ b/tools/python/xen/xend/image.pyTue Aug 22 15:30:36 2006 -0500 @@ -27,6 +27,8 @@ from xen.xend.XendLogging import log from xen.xend.XendLogging import log from xen.xend.server.netif import randomMAC from xen.xend.xenstore.xswatch import xswatch +from xen.xend import arch +from xen.xend import FlatDeviceTree xc = xen.lowlevel.xc.xc() @@ -141,19 +143,10 @@ class ImageHandler: raise VmError('Building domain failed: ostype=%s dom=%d err=%s' % (self.ostype, self.vm.getDomid(), str(result))) - -def getDomainMemory(self, mem_kb): -"""@return The memory required, in KiB, by the domain to store the -given amount, also in KiB.""" -if os.uname()[4] != 'ia64': -# A little extra because auto-ballooning is broken w.r.t. HVM -# guests. Also, slack is necessary for live migration since that -# uses shadow page tables. -if 'hvm' in xc.xeninfo()['xen_caps']: -mem_kb += 4*1024; +def getRequiredMemory(self, mem_kb): return mem_kb -def getDomainShadowMemory(self, mem_kb): +def getRequiredShadowMemory(self, mem_kb): """@return The minimum shadow memory required, in KiB, for a domain with mem_kb KiB of RAM.""" # PV domains don't need any shadow memory @@ -197,9 +190,39 @@ class LinuxImageHandler(ImageHandler): ramdisk= self.ramdisk, features = self.vm.getFeatures()) +class PPC_LinuxImageHandler(LinuxImageHandler): + +ostype = "linux" + +def configure(self, imageConfig, deviceConfig): +LinuxImageHandler.configure(self, imageConfig, deviceConfig) +self.imageConfig = im
[XenPPC] [PATCH] [XEND] abstract architecture-specific bits in image.py
# HG changeset patch # User Hollis Blanchard <[EMAIL PROTECTED]> # Date 1155763645 18000 # Node ID fcf9104665f59d886733c985ced0827be32c8874 # Parent 41827ce2ccebf927df251ce3024eb10023de7d5b [XEND] abstract architecture-specific bits in image.py - create arch.type (which evaluates to "x86", "ia64" or "powerpc") - create subclasses for x86 and ia64 HVM loaders - rework findImageHandlerClass() Signed-off-by: Hollis Blanchard <[EMAIL PROTECTED]> diff -r 41827ce2cceb -r fcf9104665f5 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Mon Aug 14 19:22:16 2006 -0500 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Aug 16 16:27:25 2006 -0500 @@ -1279,23 +1279,14 @@ class XendDomainInfo: cpu = [ int( cpus[v % len(cpus)] ) ] xc.vcpu_setaffinity(self.domid, v, cpu) -# set domain maxmem in KiB -xc.domain_setmaxmem(self.domid, self.info['maxmem'] * 1024) - -m = self.image.getDomainMemory(self.info['memory'] * 1024) -balloon.free(m) - -init_reservation = self.info['memory'] * 1024 -if os.uname()[4] in ('ia64', 'ppc64'): -# Workaround for architectures that don't yet support -# ballooning. -init_reservation = m -# Following line from [EMAIL PROTECTED] -# Needed for IA64 until supports ballooning -- okay for PPC64? -xc.domain_setmaxmem(self.domid, m) - -xc.domain_memory_increase_reservation(self.domid, init_reservation, - 0, 0) +# set memory limit +maxmem = self.image.getRequiredMemory(self.info['maxmem'] * 1024) +xc.domain_setmaxmem(self.domid, maxmem) + +# initial memory allocation +mem_kb = self.image.getRequiredMemory(self.info['memory'] * 1024) +balloon.free(mem_kb) +xc.domain_memory_increase_reservation(self.domid, mem_kb, 0, 0) self.createChannels() diff -r 41827ce2cceb -r fcf9104665f5 tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.pyMon Aug 14 19:22:16 2006 -0500 +++ b/tools/python/xen/xend/image.pyWed Aug 16 16:27:25 2006 -0500 @@ -27,6 +27,7 @@ from xen.xend.XendLogging import log from xen.xend.XendLogging import log from xen.xend.server.netif import randomMAC from xen.xend.xenstore.xswatch import xswatch +from xen.xend import arch xc = xen.lowlevel.xc.xc() @@ -141,16 +142,7 @@ class ImageHandler: raise VmError('Building domain failed: ostype=%s dom=%d err=%s' % (self.ostype, self.vm.getDomid(), str(result))) - -def getDomainMemory(self, mem_kb): -"""@return The memory required, in KiB, by the domain to store the -given amount, also in KiB.""" -if os.uname()[4] != 'ia64': -# A little extra because auto-ballooning is broken w.r.t. HVM -# guests. Also, slack is necessary for live migration since that -# uses shadow page tables. -if 'hvm' in xc.xeninfo()['xen_caps']: -mem_kb += 4*1024; +def getRequiredMemory(self, mem_kb): return mem_kb def buildDomain(self): @@ -192,8 +184,6 @@ class LinuxImageHandler(ImageHandler): features = self.vm.getFeatures()) class HVMImageHandler(ImageHandler): - -ostype = "hvm" def configure(self, imageConfig, deviceConfig): ImageHandler.configure(self, imageConfig, deviceConfig) @@ -349,21 +339,6 @@ class HVMImageHandler(ImageHandler): os.waitpid(self.pid, 0) self.pid = 0 -def getDomainMemory(self, mem_kb): -"""@see ImageHandler.getDomainMemory""" -if os.uname()[4] == 'ia64': -page_kb = 16 -# ROM size for guest firmware, ioreq page and xenstore page -extra_pages = 1024 + 2 -else: -page_kb = 4 -# This was derived emperically: -# 2.4 MB overhead per 1024 MB RAM + 8 MB constant -# + 4 to avoid low-memory condition -extra_mb = (2.4/1024) * (mem_kb/1024.0) + 12; -extra_pages = int( math.ceil( extra_mb*1024 / page_kb )) -return mem_kb + extra_pages * page_kb - def register_shutdown_watch(self): """ add xen store watch on control/shutdown """ self.shutdownWatch = xswatch(self.vm.dompath + "/control/shutdown", \ @@ -400,15 +375,42 @@ class HVMImageHandler(ImageHandler): return 1 # Keep watching -"""Table of image handler classes for virtual machine images. Indexed by -image type. -""" -imageHandlerClasses = {} - - -for h in LinuxImageHandler, HVMImageHandler: -imageHandlerClasses[h.ostype] = h - +class IA64_HVM_ImageHandler(HVMImageHandler): + +ostype = "hvm" + +def getRequiredMemory(self, mem_kb): +page_kb = 16 +# R