Add _allocMem2 for domain restore.

--
Yi Ge <[EMAIL PROTECTED]>
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1163803585 18000
# Node ID 8b64454006bbf0166b022728c1fc15b71fea426e
# Parent  b17300195f02f7da17f3ad94aed955863ffd4fed
[XenPPC] allocate memory for domain restore

Signed-off-by: Yi Ge <[EMAIL PROTECTED]>
Signed-off-by: Dan E Poff <[EMAIL PROTECTED]>

diff -r b17300195f02 -r 8b64454006bb tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Nov 14 19:46:26 2006 -0500
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Nov 17 17:46:25 2006 -0500
@@ -1338,6 +1338,69 @@ class Common_XendDomainInfo:
     def allocMem(self):
         # only for PPC
         return
+    def _allocMem2(self):
+        # Use architecture- and image-specific calculations to determine
+        # the various headrooms necessary, given the raw configured
+        # values.
+        # reservation, maxmem, memory, and shadow are all in KiB.
+        log.debug("allocMem2");
+
+        maxmem = self.info['maxmem'] * 1024
+        memory = self.info['memory'] * 1024
+        shadow = self.info['shadow_memory'] * 1024
+
+        log.debug("maxmem: 0x%08x", maxmem)
+        log.debug("memory: 0x%08x  shadow: 0x%08x", memory, shadow)
+
+        # Round shadow up to a multiple of a MiB, as shadow_mem_control
+        # takes MiB and we must not round down and end up under-providing.
+        shadow = ((shadow + 1023) / 1024) * 1024
+
+        # set memory limit
+        xc.domain_setmaxmem(self.domid, maxmem)
+
+        # Make sure there's enough RAM available for the domain
+        balloon.free(memory + shadow)
+
+        # Set up the shadow memory, i.e. the PowerPC hash table
+        shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024)
+        self.info['shadow_memory'] = shadow_cur
+
+        rma_log = 26
+        ### self.info['powerpc_rma_log']
+        if rma_log == 0:
+            # use smallest RMA size available
+            rma_log = self.getRealModeLogs()[0]
+
+        if rma_log not in self.getRealModeLogs():
+            raise ValueError("rma_log(%d) must be one of" % rma_log,
+                             self.getRealModeLogs())
+
+#        self.info['powerpc_rma_log'] = rma_log # store info for FlatDeviceTree
+
+        rma_kb = (1 << rma_log) / 1024
+        if memory < rma_kb:
+            raise ValueError("Domain memory must be at least %d KB" % rma_kb)
+
+        if memory & (16 << 10):
+            raise ValueError("Domain memory %dKB must be a multiple of 16MB"
+                             % memory)
+
+        # allocate the RMA
+        log.debug("alloc_real_mode_area(%d, %d)", self.domid, rma_log)
+        xc.alloc_real_mode_area(self.domid, rma_log)
+
+        # now allocate the remaining memory as large-order allocations
+        memory -= rma_kb
+        extent_log = 24 # 16 MB
+        page_log = 12 # 4 KB
+        extent_order = extent_log - page_log
+        log.debug("increase_reservation(%d, 0x%x, %d)", self.domid,
+                  memory, extent_order)
+        xc.domain_memory_increase_reservation(self.domid,
+                                              memory,
+                                              extent_order)
+    ## public:
 
     def cleanupDomain(self):
         """Cleanup domain resources; release devices.  Idempotent.  Nothrow
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel

Reply via email to