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-ia64-devel

Re: [Xen-devel] [PATCH] architecture-specific stuff in xend

I tried the patch on an ia64 box and it seemed to work just fine, I
think it's a great idea.

On Thu, 2006-08-10 at 16:12 -0500, Hollis Blanchard wrote:
> On Wed, 2006-08-09 at 17:18 +0100, Ewan Mellor wrote:
> > 
> > Yes, your proposal sounds fine to me. 
> 
> OK, here is the first proof-of-concept.
> 
> IA64 and HVM people will definitely need to check this over, because it
> looks like there was some *serious* bitrot in this area. (For example, I
> can't see how an HVM domain would have made it into class ImageHandler
> in the first place.)
> 
> John, would you extend this scheme to cover host OS differences? I think
> it's worth separating the attributes of the host and the guest, and this
> patch below is all about guest stuff. W.R.T.
> tools/python/xen/util/Brctl.py, wouldn't it make more sense to replace
> that file entirely depending on the host OS?
> 
> 
> 
> [XEND] Abstract architecture-specific guest code into a module.
> Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
> 
> diff -r 8cca42e2610a tools/python/xen/xend/XendDomainInfo.py
> --- a/tools/python/xen/xend/XendDomainInfo.py Thu Aug 10 14:29:04 2006 +0100
> +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Aug 10 15:45:00 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 xiantao.zhang@xxxxxxxxx
> -                # 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 8cca42e2610a tools/python/xen/xend/image.py
> --- a/tools/python/xen/xend/image.py  Thu Aug 10 14:29:04 2006 +0100
> +++ b/tools/python/xen/xend/image.py  Thu Aug 10 15:45:21 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,17 +142,8 @@ 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;
> -        return mem_kb
> +    def getRequiredMemory(self, domain_kb):
> +        return domain_kb
>  
>      def buildDomain(self):
>          """Build the domain. Define in subclass."""
> @@ -349,20 +341,8 @@ 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 getRequiredMemory(self, domain_kb):
> +        return arch.HVMRequiredMemory(domain_kb)
>  
>      def register_shutdown_watch(self):
>          """ add xen store watch on control/shutdown """
> diff -r 8cca42e2610a tools/python/xen/xend/arch/__init__.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/python/xen/xend/arch/__init__.py  Thu Aug 10 15:18:58 2006 -0500
> @@ -0,0 +1,28 @@
> +#!/usr/bin/env python
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of version 2.1 of the GNU Lesser General Public
> +# License as published by the Free Software Foundation.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +#
> +# Copyright (C) IBM Corp. 2006
> +#
> +# Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
> +
> +import os
> +
> +_uname = os.uname()[4] 
> +if _uname in ("i386", "i486", "i586", "i686"):
> +     from x86 import *
> +elif _uname in ("ia64"):
> +     from ia64 import *
> +elif _uname in ("ppc", "ppc64"):
> +     from powerpc import *
> diff -r 8cca42e2610a tools/python/xen/xend/arch/ia64.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/python/xen/xend/arch/ia64.py      Thu Aug 10 15:45:08 2006 -0500
> @@ -0,0 +1,24 @@
> +#!/usr/bin/env python
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of version 2.1 of the GNU Lesser General Public
> +# License as published by the Free Software Foundation.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +#
> +# Copyright (C) IBM Corp. 2006
> +#
> +# Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
> +
> +def HVMRequiredMemory(mem_kb):
> +    page_kb = 16
> +    # ROM size for guest firmware, ioreq page and xenstore page
> +    extra_pages = 1024 + 2
> +    return mem_kb + extra_pages * page_kb
> diff -r 8cca42e2610a tools/python/xen/xend/arch/x86.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/python/xen/xend/arch/x86.py       Thu Aug 10 15:45:13 2006 -0500
> @@ -0,0 +1,27 @@
> +#!/usr/bin/env python
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of version 2.1 of the GNU Lesser General Public
> +# License as published by the Free Software Foundation.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library; if not, write to the Free Software
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +#
> +# Copyright (C) IBM Corp. 2006
> +#
> +# Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
> +
> +def HVMRequiredMemory(mem_kb):
> +    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
> 
> 
> 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel