3 files changed, 71 insertions(+), 73 deletions(-)
tools/libxc/powerpc64/xc_linux_build.c | 70 ++++++++++++++++++++++++++++++-
tools/python/xen/xend/XendDomainInfo.py | 68 ------------------------------
tools/python/xen/xend/image.py | 6 --
# HG changeset patch
# User Ryan Harper <ryanh@xxxxxxxxxx>
# Date 1169241710 21600
# Node ID 00c682cf4b4397a4ed25b7b21fefc429f4196d0d
# Parent 9c743efd5129266689118213daa0d5032b529b20
[PATCH] move ppc memory allocation to libxc. Sync XendDomainInfo.py with
xen-unstable.hg.
Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
diff -r 9c743efd5129 -r 00c682cf4b43 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c Fri Jan 19 15:21:50 2007 -0600
+++ b/tools/libxc/powerpc64/xc_linux_build.c Fri Jan 19 15:21:50 2007 -0600
@@ -142,7 +142,41 @@ static void free_page_array(xen_pfn_t *p
free(page_array);
}
-
+static int check_memory_config(int rma_log, unsigned int mem_mb)
+{
+ u64 mem_kb = (mem_mb << 10);
+ u64 rma_kb = (1 << rma_log) >> 10;
+
+ switch(rma_log)
+ {
+ case 26:
+ case 27:
+ case 28:
+ case 30:
+ case 34:
+ case 38:
+ if (mem_kb < rma_kb) {
+ DPRINTF("Domain memory must be at least %dMB\n",
+ (1 << rma_log)>>20);
+ break;
+ }
+
+ if (mem_kb % (16 << 10)) {
+ DPRINTF("Domain memory %dMB must be a multiple of 16MB\n",
+ mem_mb);
+
+ break;
+ }
+
+ /* rma_log and mem_mb OK */
+ return 0;
+
+ default:
+ DPRINTF("Invalid rma_log (%d)\n", rma_log);
+ }
+
+ return 1;
+}
int xc_linux_build(int xc_handle,
uint32_t domid,
@@ -168,6 +202,9 @@ int xc_linux_build(int xc_handle,
unsigned long start_info_addr;
unsigned long rma_pages;
unsigned long shadow_mb;
+ u32 remaining_kb;
+ u32 extent_order;
+ u64 nr_extents;
int rma_log = 26; /* 64MB RMA */
int rc = 0;
int op;
@@ -181,6 +218,37 @@ int xc_linux_build(int xc_handle,
rma_pages = (1 << rma_log) >> PAGE_SHIFT;
if (rma_pages == 0) {
+ rc = -1;
+ goto out;
+ }
+
+ /* validate rma_log and domain memory config */
+ if (check_memory_config(rma_log, mem_mb)) {
+ rc = -1;
+ goto out;
+ }
+
+ /* alloc RMA */
+ if (xc_alloc_real_mode_area(xc_handle, domid, rma_log)) {
+ rc = -1;
+ goto out;
+ }
+
+ /* subtract already allocated RMA to determine remaining KB to alloc */
+ remaining_kb = (nr_pages - rma_pages) * (PAGE_SIZE / 1024);
+ DPRINTF("totalmem - RMA = %dKB\n", remaining_kb);
+
+ /* to allocate in 16MB chunks, we need to determine the order of
+ * the number of PAGE_SIZE pages contained in 16MB. */
+ extent_order = 24 - 12; /* extent_order = log2((1 << 24) - (1 << 12)) */
+ nr_extents = (remaining_kb / (PAGE_SIZE/1024)) >> extent_order;
+ DPRINTF("allocating memory in %llu chunks of %luMB\n", nr_extents,
+ (((1 << extent_order) >> 10) * PAGE_SIZE) >> 10);
+
+ /* now allocate the remaining memory as large-order allocations */
+ DPRINTF("increase_reservation(%u, %llu, %u)\n", domid, nr_extents,
extent_order);
+ if (xc_domain_memory_increase_reservation(xc_handle, domid, nr_extents,
+ extent_order, 0, NULL)) {
rc = -1;
goto out;
}
diff -r 9c743efd5129 -r 00c682cf4b43 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Fri Jan 19 15:21:50 2007 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Jan 19 15:21:50 2007 -0600
@@ -290,7 +290,7 @@ def dom_get(dom):
return None
-class Common_XendDomainInfo:
+class XendDomainInfo:
"""An object represents a domain.
@TODO: try to unify dom and domid, they mean the same thing, but
@@ -1409,9 +1409,6 @@ class Common_XendDomainInfo:
shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024)
self.info['shadow_memory'] = shadow_cur
- ### PPC
- self.allocMem()
-
self._createChannels()
channel_details = self.image.createImage()
@@ -1434,9 +1431,6 @@ class Common_XendDomainInfo:
self.image.cleanupBootloading()
raise VmError(str(exn))
- def allocMem(self):
- # only for PPC
- return
def cleanupDomain(self):
"""Cleanup domain resources; release devices. Idempotent. Nothrow
@@ -2134,63 +2128,3 @@ class Common_XendDomainInfo:
__repr__ = __str__
-
-
-#
-# This change is only in the PPC tree and is done this way to ease
-# maintanence until the correct solution is made
-#
-
-
-class XendDomainInfo (Common_XendDomainInfo):
- def arch(self):
- return "powerpc"
-
- _rmaLogs = {
- "970": (26, 27, 28, 30, 34, 38),
- }
-
- def getRealModeLogs(self):
- """Returns a list of RMA sizes this processor supports."""
- cputype = "970" # XXX extract from cpuinfo or device tree
- return self._rmaLogs[cputype]
-
- def allocMem(self):
- memory = self.image.getRequiredAvailableMemory(
- self.info['memory_static_min'] * 1024)
-
- 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())
-
- # store info for FlatDeviceTree
- ### self.info['powerpc_rma_log'] = rma_log
-
- 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)
-
diff -r 9c743efd5129 -r 00c682cf4b43 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py Fri Jan 19 15:21:50 2007 -0600
+++ b/tools/python/xen/xend/image.py Fri Jan 19 15:21:50 2007 -0600
@@ -216,13 +216,9 @@ class LinuxImageHandler(ImageHandler):
-class PPC_ProseImageHandler(ImageHandler):
+class PPC_ProseImageHandler(LinuxImageHandler):
ostype = "prose"
-
- def configure(self, vmConfig, imageConfig, deviceConfig):
- LinuxImageHandler.configure(self, vmConfig, imageConfig, deviceConfig)
- self.imageConfig = imageConfig
def buildDomain(self):
store_evtchn = self.vm.getStorePort()
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|