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

[XenPPC][Patch 1/3] xen patches for xm save/restore



diff -r 9148f7816d00 config/powerpc64.mk
--- a/config/powerpc64.mk    Tue Oct 24 19:11:00 2006 -0400
+++ b/config/powerpc64.mk    Wed Nov 01 10:05:21 2006 -0500
@@ -3,3 +3,4 @@ CONFIG_POWERPC_$(XEN_OS) := y

 CFLAGS += -DELFSIZE=64
 LIBDIR := lib
+CONFIG_XCUTILS :=y
diff -r 9148f7816d00 tools/libxc/powerpc64/Makefile
--- a/tools/libxc/powerpc64/Makefile    Tue Oct 24 19:11:00 2006 -0400
+++ b/tools/libxc/powerpc64/Makefile    Wed Nov 01 10:06:23 2006 -0500
@@ -2,5 +2,7 @@ GUEST_SRCS-y += powerpc64/xc_linux_build
 GUEST_SRCS-y += powerpc64/xc_linux_build.c
 GUEST_SRCS-y += powerpc64/xc_prose_build.c
 GUEST_SRCS-y += powerpc64/utils.c
+GUEST_SRCS-y += powerpc64/xc_ppc_linux_save.c
+GUEST_SRCS-y += powerpc64/xc_ppc_linux_restore.c

 CTRL_SRCS-y += powerpc64/xc_memory.c
diff -r 9148f7816d00 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c    Tue Oct 24 19:11:00 2006 -0400
+++ b/tools/libxc/xc_private.c    Wed Nov 01 10:07:55 2006 -0500
@@ -306,6 +306,25 @@ int xc_get_pfn_list(int xc_handle,

     return (ret < 0) ? -1 : domctl.u.getmemlist.num_pfns;
 }
+
+int xc_get_shadow_list( int xc_handle,
+                       uint32_t domid,
+                       uint64_t *htab_raddr)
+{
+    DECLARE_DOMCTL;
+    int ret;
+
+    domctl.cmd = XEN_DOMCTL_getshadowlist;
+    domctl.domain = (domid_t)domid;
+
+    DPRINTF("xc_get_shadow_list() running \n");
+
+    ret = do_domctl(xc_handle, &domctl);
+    *htab_raddr = domctl.u.getshadowlist.htab_map;
+
+    return (ret < 0) ? -1 : domctl.u.getshadowlist.htab_num_ptes;
+}
+
 #endif

 long xc_get_tot_pages(int xc_handle, uint32_t domid)
diff -r 9148f7816d00 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h    Tue Oct 24 19:11:00 2006 -0400
+++ b/tools/libxc/xenctrl.h    Wed Nov 01 10:08:46 2006 -0500
@@ -529,6 +529,8 @@ int xc_get_pfn_list(int xc_handle, uint3
 int xc_get_pfn_list(int xc_handle, uint32_t domid, xen_pfn_t *pfn_buf,
                     unsigned long max_pfns);

+int xc_get_shadow_list(int xc_handle, uint32_t domid, uint64_t *mfn_htab_map);
+
 int xc_ia64_get_pfn_list(int xc_handle, uint32_t domid,
                          xen_pfn_t *pfn_buf,
                          unsigned int start_page, unsigned int nr_pages);
diff -r 9148f7816d00 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Tue Oct 24 19:11:00 2006 -0400 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Nov 01 16:40:21 2006 -0500
@@ -270,6 +270,7 @@ def restore(config):
vm = findDomainClass()(parseConfig(config), None, None, False, False, True)
     try:
         vm.construct()
+        vm.allocMem2()
         vm.storeVmDetails()
         vm.createDevices()
         vm.createChannels()
@@ -1369,6 +1370,66 @@ class XendDomainInfo:
         xc.domain_memory_increase_reservation(self.domid, reservation, 0,
                                               0)

+
+
+    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 = 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)
+
+        # 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)
+

     ## public:


_______________________________________________
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®.