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

[XenPPC] [PATCH] architecture-specific stuff in xend

Here is the update. Special thanks to Dan Stekloff and Daniel Miles, who
tested on HVM and IA64, respectively.

Ewan, please apply.

[XEND] Abstract architecture-specific guest code into a module.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>

diff -r 8cca42e2610a tools/python/setup.py
--- a/tools/python/setup.py     Thu Aug 10 14:29:04 2006 +0100
+++ b/tools/python/setup.py     Mon Aug 14 11:56:40 2006 -0500
@@ -51,6 +51,7 @@ setup(name            = 'xen',
                          'xen.web',
                          'xen.sv',
 
+                         'xen.xend.arch',
                          'xen.xend.tests',
                          'xen.xend.server.tests',
                          'xen.xend.xenstore.tests',
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    Mon Aug 14 11:46:46 2006 -0500
@@ -19,7 +19,6 @@
 
 import os, string
 import re
-import math
 
 import xen.lowlevel.xc
 from xen.xend import sxp
@@ -27,6 +26,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 +141,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 +340,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 Mon Aug 14 11:46:35 2006 -0500
@@ -0,0 +1,29 @@
+#!/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 math
+
+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


-- 
Hollis Blanchard
IBM Linux Technology Center


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