WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4/7] move the suspend_ctx on the save stack instead o

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 4/7] move the suspend_ctx on the save stack instead of a global one
From: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
Date: Fri, 13 Nov 2009 23:43:04 +0000
Cc: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
Delivery-date: Fri, 13 Nov 2009 15:42:06 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1258155787-28327-1-git-send-email-vincent.hanquez@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1258155787-28327-1-git-send-email-vincent.hanquez@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
move the suspend_ctx on the save stack instead of a global one

---
 tools/libxc/xc_domain_save.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
index 97bd4ad..341b0e0 100644
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -41,13 +41,6 @@ struct suspend_ctx {
     xen_pfn_t *live_p2m; /* Live mapping of the table mapping each PFN to its 
current MFN. */
 };
 
-struct suspend_ctx _ctx = {
-       .live_p2m = NULL,
-       .live_m2p = NULL,
-};
-
-struct suspend_ctx *ctx = &_ctx;
-
 /* buffer for output */
 struct outbuf {
     void* buf;
@@ -398,6 +391,7 @@ static int print_stats(int xc_handle, uint32_t domid, int 
pages_sent,
 
 
 static int analysis_phase(int xc_handle, uint32_t domid,
+                          struct suspend_ctx *ctx,
                           unsigned long *arr, int runs)
 {
     long long start, now;
@@ -454,6 +448,7 @@ static int suspend_and_state(int (*suspend)(void*), void* 
data,
 ** it to update the MFN to a reasonable value.
 */
 static void *map_frame_list_list(int xc_handle, uint32_t dom,
+                                 struct suspend_ctx *ctx,
                                  shared_info_any_t *shinfo)
 {
     int count = 100;
@@ -488,7 +483,8 @@ static void *map_frame_list_list(int xc_handle, uint32_t 
dom,
 ** which entries do not require canonicalization (in particular, those
 ** entries which map the virtual address reserved for the hypervisor).
 */
-static int canonicalize_pagetable(unsigned long type, unsigned long pfn,
+static int canonicalize_pagetable(struct suspend_ctx *ctx,
+                           unsigned long type, unsigned long pfn,
                            const void *spage, void *dpage)
 {
 
@@ -669,6 +665,7 @@ err0:
 static xen_pfn_t *map_and_save_p2m_table(int xc_handle, 
                                          int io_fd, 
                                          uint32_t dom,
+                                         struct suspend_ctx *ctx,
                                          shared_info_any_t *live_shinfo)
 {
     vcpu_guest_context_any_t ctxt;
@@ -686,7 +683,7 @@ static xen_pfn_t *map_and_save_p2m_table(int xc_handle,
 
     int i, success = 0;
 
-    live_p2m_frame_list_list = map_frame_list_list(xc_handle, dom,
+    live_p2m_frame_list_list = map_frame_list_list(xc_handle, dom, ctx,
                                                    live_shinfo);
     if ( !live_p2m_frame_list_list )
         goto out;
@@ -892,9 +889,14 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, 
uint32_t max_iters,
     unsigned long mfn;
 
     struct outbuf ob;
-
     int completed = 0;
 
+    struct suspend_ctx _ctx = {
+        .live_p2m = NULL,
+        .live_m2p = NULL,
+    };
+    struct suspend_ctx *ctx = &_ctx;
+
     outbuf_init(&ob, OUTBUF_SIZE);
 
     /* If no explicit control parameters given, use defaults */
@@ -1022,7 +1024,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t 
dom, uint32_t max_iters,
         }
     }
 
-    analysis_phase(xc_handle, dom, to_skip, 0);
+    analysis_phase(xc_handle, dom, ctx, to_skip, 0);
 
     pfn_type   = xg_memalign(PAGE_SIZE, ROUNDUP(
                               MAX_BATCH_SIZE * sizeof(*pfn_type), PAGE_SHIFT));
@@ -1061,7 +1063,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t 
dom, uint32_t max_iters,
         int err = 0;
 
         /* Map the P2M table, and write the list of P2M frames */
-        ctx->live_p2m = map_and_save_p2m_table(xc_handle, io_fd, dom, 
live_shinfo);
+        ctx->live_p2m = map_and_save_p2m_table(xc_handle, io_fd, dom, ctx, 
live_shinfo);
         if ( ctx->live_p2m == NULL )
         {
             ERROR("Failed to map/save the p2m frame list");
@@ -1349,7 +1351,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t 
dom, uint32_t max_iters,
                 {
                     /* We have a pagetable page: need to rewrite it. */
                     race = 
-                        canonicalize_pagetable(pagetype, pfn, spage, page); 
+                        canonicalize_pagetable(ctx, pagetype, pfn, spage, 
page); 
 
                     if ( race && !live )
                     {
-- 
1.6.5.2


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