[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XenPPC] [xenppc-unstable] [TOOLS][POWERPC] merge



# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID e0330d789a40959acc267ec342a6f907a8d73abc
# Parent  4d4f0d52c1934a50a67d3fe9bd30b4f7e23427fe
[TOOLS][POWERPC] merge

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
 tools/libxc/powerpc64/utils.c           |    2 
 tools/libxc/powerpc64/xc_linux_build.c  |    4 -
 tools/libxc/powerpc64/xc_prose_build.c  |    4 -
 tools/libxc/xenguest.h                  |    1 
 tools/python/xen/lowlevel/xc/xc.c       |   11 ++--
 tools/python/xen/xend/FlatDeviceTree.py |    2 
 tools/python/xen/xend/XendDomainInfo.py |   84 +++++++++++++++++++++++++++++++-
 tools/python/xen/xend/image.py          |    1 
 8 files changed, 97 insertions(+), 12 deletions(-)

diff -r 4d4f0d52c193 -r e0330d789a40 tools/libxc/powerpc64/utils.c
--- a/tools/libxc/powerpc64/utils.c     Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/libxc/powerpc64/utils.c     Fri Nov 10 15:19:56 2006 -0500
@@ -77,7 +77,7 @@ int get_rma_page_array(int xc_handle, in
     /* We know that the RMA is machine contiguous so lets just get the
      * first MFN and fill the rest in ourselves */
     rc = xc_get_pfn_list(xc_handle, domid, *page_array, 1);
-    if (rc != 1) {
+    if (rc == -1) {
         perror("Could not get the page frame list");
         return -1;
     }
diff -r 4d4f0d52c193 -r e0330d789a40 tools/libxc/powerpc64/xc_linux_build.c
--- a/tools/libxc/powerpc64/xc_linux_build.c    Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/libxc/powerpc64/xc_linux_build.c    Fri Nov 10 15:19:56 2006 -0500
@@ -229,6 +229,7 @@ static void free_page_array(xen_pfn_t *p
 
 int xc_linux_build(int xc_handle,
                    uint32_t domid,
+                   unsigned int mem_mb,
                    const char *image_name,
                    const char *initrd_name,
                    const char *cmdline,
@@ -254,8 +255,7 @@ int xc_linux_build(int xc_handle,
 
     DPRINTF("%s\n", __func__);
 
-    DPRINTF("xc_get_tot_pages\n");
-    nr_pages = xc_get_tot_pages(xc_handle, domid);
+    nr_pages = mem_mb << (20 - PAGE_SHIFT);
     DPRINTF("nr_pages 0x%lx\n", nr_pages);
 
     rma_pages = get_rma_pages(devtree);
diff -r 4d4f0d52c193 -r e0330d789a40 tools/libxc/powerpc64/xc_prose_build.c
--- a/tools/libxc/powerpc64/xc_prose_build.c    Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/libxc/powerpc64/xc_prose_build.c    Fri Nov 10 15:19:56 2006 -0500
@@ -230,6 +230,7 @@ static void free_page_array(xen_pfn_t *p
 
 int xc_prose_build(int xc_handle,
                    uint32_t domid,
+                   unsigned int mem_mb,
                    const char *image_name,
                    const char *initrd_name,
                    const char *cmdline,
@@ -257,8 +258,7 @@ int xc_prose_build(int xc_handle,
 
     DPRINTF("cmdline=%s\n", cmdline);
 
-    DPRINTF("xc_get_tot_pages\n");
-    nr_pages = xc_get_tot_pages(xc_handle, domid);
+    nr_pages = mem_mb << (20 - PAGE_SHIFT);
     DPRINTF("nr_pages 0x%lx\n", nr_pages);
 
     rma_pages = get_rma_pages(devtree);
diff -r 4d4f0d52c193 -r e0330d789a40 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/libxc/xenguest.h    Fri Nov 10 15:19:56 2006 -0500
@@ -131,6 +131,7 @@ int xc_hvm_build_mem(int xc_handle,
 
 int xc_prose_build(int xc_handle,
                    uint32_t domid,
+                   unsigned int mem_mb,
                    const char *image_name,
                    const char *ramdisk_name,
                    const char *cmdline,
diff -r 4d4f0d52c193 -r e0330d789a40 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/python/xen/lowlevel/xc/xc.c Fri Nov 10 15:19:56 2006 -0500
@@ -347,7 +347,7 @@ static PyObject *pyxc_linux_build(XcObje
                                 "ramdisk", "cmdline", "flags",
                                 "features", "arch_args", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssiss#", kwd_list,
                                       &dom, &store_evtchn, &mem_mb,
                                       &console_evtchn, &image,
                                       /* optional */
@@ -377,26 +377,27 @@ static PyObject *pyxc_prose_build(XcObje
     char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
     int flags = 0;
     int store_evtchn, console_evtchn;
+    unsigned int mem_mb;
     unsigned long store_mfn = 0;
     unsigned long console_mfn = 0;
     void *arch_args = NULL;
     int unused;
 
-    static char *kwd_list[] = { "dom", "store_evtchn",
+    static char *kwd_list[] = { "dom", "store_evtchn", "memsize",
                                 "console_evtchn", "image",
                                 /* optional */
                                 "ramdisk", "cmdline", "flags",
                                 "features", "arch_args", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssiss#", kwd_list,
-                                      &dom, &store_evtchn,
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssiss#", kwd_list,
+                                      &dom, &store_evtchn, &mem_mb,
                                       &console_evtchn, &image,
                                       /* optional */
                                       &ramdisk, &cmdline, &flags,
                                       &features, &arch_args, &unused) )
         return NULL;
 
-    if ( xc_prose_build(self->xc_handle, dom, image,
+    if ( xc_prose_build(self->xc_handle, dom, mem_mb, image,
                         ramdisk, cmdline, features, flags,
                         store_evtchn, &store_mfn,
                         console_evtchn, &console_mfn,
diff -r 4d4f0d52c193 -r e0330d789a40 tools/python/xen/xend/FlatDeviceTree.py
--- a/tools/python/xen/xend/FlatDeviceTree.py   Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/python/xen/xend/FlatDeviceTree.py   Fri Nov 10 15:19:56 2006 -0500
@@ -298,7 +298,7 @@ def build(imghandler):
 
     # add memory nodes
     totalmem = imghandler.vm.getMemoryTarget() * 1024
-    rma_log = imghandler.vm.info.get('powerpc_rma_log')
+    rma_log = 26 ### imghandler.vm.info.get('powerpc_rma_log')
     rma_bytes = 1 << rma_log
 
     # RMA node
diff -r 4d4f0d52c193 -r e0330d789a40 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Nov 10 15:19:56 2006 -0500
@@ -315,7 +315,7 @@ def dom_get(dom):
     return None
 
 
-class XendDomainInfo:
+class Common_XendDomainInfo:
     """An object represents a domain.
 
     @TODO: try to unify dom and domid, they mean the same thing, but
@@ -2003,3 +2003,85 @@ class 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):
+        # 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.
+        reservation = self.image.getRequiredInitialReservation(
+            self.info['memory'] * 1024)
+        maxmem = self.image.getRequiredAvailableMemory(
+            self.info['maxmem'] * 1024)
+        memory = self.image.getRequiredAvailableMemory(
+            self.info['memory'] * 1024)
+        shadow = self.image.getRequiredShadowMemory(
+            self.info['shadow_memory'] * 1024,
+            self.info['maxmem'] * 1024)
+        # 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)
+        dev_uuid = self.info.device_add('vtpm', cfg_xenapi = xenapi_vtpm)
+ 
+        # 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())
+
+        # 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)
+
+        # allocate the RMA
+        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
+        extent_size = 1 << extent_log
+        page_log = 12 # 4 KB
+        extent_order = extent_log - page_log
+        for i in range(0, memory * 1024, extent_size):
+            log.debug("increase_reservation(%d, 0x%x, %d)", self.domid,
+                    extent_size >> 10, extent_order)
+            xc.domain_memory_increase_reservation(self.domid,
+                                                  extent_size >> 10,
+                                                  extent_order)
+
diff -r 4d4f0d52c193 -r e0330d789a40 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Nov 09 15:37:17 2006 -0500
+++ b/tools/python/xen/xend/image.py    Fri Nov 10 15:19:56 2006 -0500
@@ -279,6 +279,7 @@ class PPC_ProseImageHandler(LinuxImageHa
         devtree = FlatDeviceTree.build(self)
 
         return xc.prose_build(dom            = self.vm.getDomid(),
+                              memsize        = mem_mb,
                               image          = self.kernel,
                               store_evtchn   = store_evtchn,
                               console_evtchn = console_evtchn,

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.