Skip to contentSkip to conversation

abstract architecture-specific bits in image.py

PATCH New Hollis Blanchard 2 participants 6 messages Aug 16, 2006 – Aug 30, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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()

tools/python/xen/xend/XendDomainInfo.py +8 -17
diff -r 41827ce2cceb -r fcf9104665f5 tools/python/xen/xend/XendDomainInfo.py
@@ -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()
 
tools/python/xen/xend/image.py +44 -42

120 lines not on this page · raw message

tools/python/xen/xend/arch.py new file +31 -0
diff -r 41827ce2cceb -r fcf9104665f5 tools/python/xen/xend/arch.py
@@ -0,0 +1,31 @@
+#!/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 <[email protected]>
+
+import os
+
+_types = {
+	"i386": "x86",
+	"i486": "x86",
+	"i586": "x86",
+	"i686": "x86",
+	"ia64": "ia64",
+	"ppc": "powerpc",
+	"ppc64": "powerpc",
+}
+type = _types.get(os.uname()[4], "unknown")
#1 lore raw

PATCH 1/1 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()

tools/python/xen/xend/XendDomainInfo.py +15 -23
diff -r 5fc1fe790835 tools/python/xen/xend/XendDomainInfo.py
@@ -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()
 
tools/python/xen/xend/image.py +87 -54

178 lines not on this page · raw message

tools/python/xen/xend/FlatDeviceTree.py new file +323 -0

323 lines not on this page · raw message

tools/python/xen/xend/arch.py new file +31 -0
diff -r 5fc1fe790835 tools/python/xen/xend/arch.py
@@ -0,0 +1,31 @@
+#!/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 <[email protected]>
+
+import os
+
+_types = {
+    "i386": "x86",
+    "i486": "x86",
+    "i586": "x86",
+    "i686": "x86",
+    "ia64": "ia64",
+    "ppc": "powerpc",
+    "ppc64": "powerpc",
+}
+type = _types.get(os.uname()[4], "unknown")
Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#2 lore raw
Quoted 3 lines · Hollis Blanchard

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.

Tim, could you confirm this doesn't break the shadow code please?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
Applied
#3 lore raw
In reply to Hollis Blanchard
Quoted 5 lines · Hollis Blanchard

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.

Applied, thanks Hollis. Is this your only outstanding patch? I got lost when you rev'd this one a couple of times ;-)

Thanks,

Ewan.

#4 lore raw
Quoted 10 lines · Ewan Mellor
Quoted 5 lines · Hollis Blanchard

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.

Applied, thanks Hollis. Is this your only outstanding patch? I got lost when you rev'd this one a couple of times ;-)

Thanks Ewan! I will have another patch for you shortly. :)

Actually there was one bug we discovered as a result of the shadow
merge: shadow_mem_control's arguments should be MB, not bytes. Here's the pseudo-diff:
- shadow_cur = xc.shadow_mem_control(self.domid, shadow_kb * 1024)
+ shadow_cur = xc.shadow_mem_control(self.domid, shadow_kb / 1024)

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#5 lore raw
Quoted 17 lines · Hollis Blanchard
Quoted 10 lines · Ewan Mellor
Quoted 5 lines · Hollis Blanchard

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.

Applied, thanks Hollis. Is this your only outstanding patch? I got lost when you rev'd this one a couple of times ;-)

Thanks Ewan! I will have another patch for you shortly. :)

Actually there was one bug we discovered as a result of the shadow
merge: shadow_mem_control's arguments should be MB, not bytes. Here's the pseudo-diff:

Review

Quoted 2 lines
(quoted diff) +1 -1
-            shadow_cur = xc.shadow_mem_control(self.domid, shadow_kb * 1024)
+            shadow_cur = xc.shadow_mem_control(self.domid, shadow_kb / 1024)

I've done that, but with (shadow_kb + 1023) / 1024, as it needs to be rounded up.

Cheers,

Ewan.