From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Miles Subject: Re: [PATCH] architecture-specific stuff in xend Date: Fri, 11 Aug 2006 16:59:18 -0600 Message-ID: <1155337158.9030.41.camel@localhost.localdomain> References: <1155051266.30116.152.camel@basalt.austin.ibm.com> <20060808155953.GA20410@totally.trollied.org> <20060809092810.GC19705@leeni.uk.xensource.com> <1155136032.2821.6.camel@diesel> <20060809161811.GD26245@leeni.uk.xensource.com> <1155244357.2833.23.camel@basalt.austin.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1302100341==" Return-path: In-Reply-To: <1155244357.2833.23.camel@basalt.austin.ibm.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Hollis Blanchard Cc: John Levon , xen-ia64-devel , Ewan Mellor , xen-devel , xen-ppc-devel List-Id: xen-devel@lists.xenproject.org --===============1302100341== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-/XSlOx06kKrwLFA+58ER" --=-/XSlOx06kKrwLFA+58ER Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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: > >=20 > > Yes, your proposal sounds fine to me.=20 >=20 > OK, here is the first proof-of-concept. >=20 > 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.) >=20 > 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? >=20 >=20 >=20 > [XEND] Abstract architecture-specific guest code into a module. > Signed-off-by: Hollis Blanchard >=20 > diff -r 8cca42e2610a tools/python/xen/xend/XendDomainInfo.py > --- a/tools/python/xen/xend/XendDomainInfo.py Thu Aug 10 14:29:04 2006 +0= 100 > +++ b/tools/python/xen/xend/XendDomainInfo.py Thu Aug 10 15:45:00 2006 -0= 500 > @@ -1279,23 +1279,14 @@ class XendDomainInfo: > cpu =3D [ int( cpus[v % len(cpus)] ) ] > xc.vcpu_setaffinity(self.domid, v, cpu) > =20 > - # set domain maxmem in KiB > - xc.domain_setmaxmem(self.domid, self.info['maxmem'] * 1024) > - > - m =3D self.image.getDomainMemory(self.info['memory'] * 1024) > - balloon.free(m) > - > - init_reservation =3D self.info['memory'] * 1024 > - if os.uname()[4] in ('ia64', 'ppc64'): > - # Workaround for architectures that don't yet support > - # ballooning. > - init_reservation =3D m > - # Following line from xiantao.zhang@intel.com > - # Needed for IA64 until supports ballooning -- okay for = PPC64? > - xc.domain_setmaxmem(self.domid, m) > - > - xc.domain_memory_increase_reservation(self.domid, init_reser= vation, > - 0, 0) > + # set memory limit > + maxmem =3D self.image.getRequiredMemory(self.info['maxmem'] = * 1024) > + xc.domain_setmaxmem(self.domid, maxmem) > + > + # initial memory allocation > + mem_kb =3D self.image.getRequiredMemory(self.info['memory'] = * 1024) > + balloon.free(mem_kb) > + xc.domain_memory_increase_reservation(self.domid, mem_kb, 0,= 0) > =20 > self.createChannels() > =20 > 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 > =20 >=20 > xc =3D xen.lowlevel.xc.xc() > @@ -141,17 +142,8 @@ class ImageHandler: > raise VmError('Building domain failed: ostype=3D%s dom=3D%d = err=3D%s' > % (self.ostype, self.vm.getDomid(), str(result= ))) > =20 > - > - def getDomainMemory(self, mem_kb): > - """@return The memory required, in KiB, by the domain to store t= he > - given amount, also in KiB.""" > - if os.uname()[4] !=3D 'ia64': > - # A little extra because auto-ballooning is broken w.r.t. HV= M > - # guests. Also, slack is necessary for live migration since = that > - # uses shadow page tables. > - if 'hvm' in xc.xeninfo()['xen_caps']: > - mem_kb +=3D 4*1024; > - return mem_kb > + def getRequiredMemory(self, domain_kb): > + return domain_kb > =20 > def buildDomain(self): > """Build the domain. Define in subclass.""" > @@ -349,20 +341,8 @@ class HVMImageHandler(ImageHandler): > os.waitpid(self.pid, 0) > self.pid =3D 0 > =20 > - def getDomainMemory(self, mem_kb): > - """@see ImageHandler.getDomainMemory""" > - if os.uname()[4] =3D=3D 'ia64': > - page_kb =3D 16 > - # ROM size for guest firmware, ioreq page and xenstore page > - extra_pages =3D 1024 + 2 > - else: > - page_kb =3D 4 > - # This was derived emperically: > - # 2.4 MB overhead per 1024 MB RAM + 8 MB constant > - # + 4 to avoid low-memory condition > - extra_mb =3D (2.4/1024) * (mem_kb/1024.0) + 12; > - extra_pages =3D 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) > =20 > 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 -05= 00 > @@ -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 Pub= lic > +# 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 > + > +import os > + > +_uname =3D os.uname()[4]=20 > +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 Pub= lic > +# 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 > + > +def HVMRequiredMemory(mem_kb): > + page_kb =3D 16 > + # ROM size for guest firmware, ioreq page and xenstore page > + extra_pages =3D 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 Pub= lic > +# 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 > + > +def HVMRequiredMemory(mem_kb): > + page_kb =3D 4 > + # This was derived emperically: > + # 2.4 MB overhead per 1024 MB RAM + 8 MB constant > + # + 4 to avoid low-memory condition > + extra_mb =3D (2.4/1024) * (mem_kb/1024.0) + 12; > + extra_pages =3D int( math.ceil( extra_mb*1024 / page_kb )) > + return mem_kb + extra_pages * page_kb >=20 >=20 >=20 --=-/XSlOx06kKrwLFA+58ER Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBE3QvGdXmokxhIjnMRAptZAJ0a11vN/xdhDV609AQb67OHLRPvTwCePXqy 7muQqxxhhesRCjIkupXZjME= =qK1u -----END PGP SIGNATURE----- --=-/XSlOx06kKrwLFA+58ER-- --===============1302100341== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1302100341==--