From: Hollis Blanchard <hollisb@us.ibm.com>
To: Ewan Mellor <ewan@xensource.com>
Cc: John Levon <levon@movementarian.org>,
xen-ia64-devel <xen-ia64-devel@lists.xensource.com>,
xen-devel <xen-devel@lists.xensource.com>,
xen-ppc-devel <xen-ppc-devel@lists.xensource.com>
Subject: [PATCH] architecture-specific stuff in xend
Date: Mon, 14 Aug 2006 12:40:08 -0500 [thread overview]
Message-ID: <1155577209.30510.92.camel@basalt.austin.ibm.com> (raw)
In-Reply-To: <20060809161811.GD26245@leeni.uk.xensource.com>
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@us.ibm.com>
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@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_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@us.ibm.com>
+
+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@us.ibm.com>
+
+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@us.ibm.com>
+
+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
next prev parent reply other threads:[~2006-08-14 17:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-08 15:34 architecture-specific stuff in xend Hollis Blanchard
2006-08-08 15:59 ` [XenPPC] Re: [Xen-devel] " John Levon
2006-08-08 16:15 ` Hollis Blanchard
2006-08-08 17:12 ` John Levon
2006-08-09 9:28 ` Ewan Mellor
2006-08-09 15:07 ` Hollis Blanchard
2006-08-09 16:18 ` Ewan Mellor
2006-08-10 21:12 ` [PATCH] " Hollis Blanchard
2006-08-10 21:27 ` John Levon
2006-08-11 22:59 ` Daniel Miles
2006-08-14 17:40 ` Hollis Blanchard [this message]
2006-08-15 2:14 ` Hollis Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1155577209.30510.92.camel@basalt.austin.ibm.com \
--to=hollisb@us.ibm.com \
--cc=ewan@xensource.com \
--cc=levon@movementarian.org \
--cc=xen-devel@lists.xensource.com \
--cc=xen-ia64-devel@lists.xensource.com \
--cc=xen-ppc-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.