$NetBSD: patch-av,v 1.1 2005/09/10 15:54:39 bouyer Exp $

--- libxc/xc_linux_save.c.orig	2005-08-03 19:57:57.000000000 -0400
+++ libxc/xc_linux_save.c	2005-09-06 23:23:44.000000000 -0400
@@ -850,11 +850,10 @@
             } /* end of the write out for this batch */
      
             sent_this_iter += batch;
+            munmap(region_base, batch*PAGE_SIZE);
 
         } /* end of this while loop for this iteration */
 
-        munmap(region_base, batch*PAGE_SIZE);
-
     skip: 
 
         total_sent += sent_this_iter;
@@ -950,7 +949,7 @@
 
 	for ( i = 0, j = 0; i < nr_pfns; i++ )
 	{
-	    if ( ! is_mapped(live_pfn_to_mfn_table[i]) )
+	    if ( ! is_mapped(live_pfn_to_mfn_table[i]) && !test_bit(i, to_fix) )
 		j++;
 	}
 
@@ -962,7 +961,7 @@
 
 	for ( i = 0, j = 0; i < nr_pfns; )
 	{
-	    if ( ! is_mapped(live_pfn_to_mfn_table[i]) )
+	    if ( ! is_mapped(live_pfn_to_mfn_table[i]) && !test_bit(i, to_fix) )
 	    {
 		pfntab[j++] = i;
 	    }
