# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1264064600 0
# Node ID 6a5d8284b6e686fd3570bdb1d4ad8aba65b41bf7
# Parent aa00760933df035e001cbb636679444fe9198e77
libxc: Unbreak HVM live migration after 0b138a019292.
0b138a019292 was a little too ambitious replacing xc_map_foreign_batch
with xc_map_foreign_pages in xc_domain_restore. With HVM, some of the
mappings are expected to fail (as "XTAB" pages).
Signed-off-by: Brendan Cully <brendan@xxxxxxxxx>
---
tools/libxc/xc_domain_restore.c | 28 +++++++++++++++++++++-------
1 files changed, 21 insertions(+), 7 deletions(-)
diff -r aa00760933df -r 6a5d8284b6e6 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Thu Jan 21 09:03:00 2010 +0000
+++ b/tools/libxc/xc_domain_restore.c Thu Jan 21 09:03:20 2010 +0000
@@ -1171,6 +1171,8 @@ static int apply_batch(int xc_handle, ui
unsigned long *page = NULL;
int nraces = 0;
struct domain_info_context *dinfo = &ctx->dinfo;
+ int* pfn_err = NULL;
+ int rc = -1;
unsigned long mfn, pfn, pagetype;
@@ -1186,12 +1188,14 @@ static int apply_batch(int xc_handle, ui
}
/* Map relevant mfns */
- region_base = xc_map_foreign_pages(
- xc_handle, dom, PROT_WRITE, region_mfn, j);
+ pfn_err = calloc(j, sizeof(*pfn_err));
+ region_base = xc_map_foreign_bulk(
+ xc_handle, dom, PROT_WRITE, region_mfn, pfn_err, j);
if ( region_base == NULL )
{
ERROR("map batch failed");
+ free(pfn_err);
return -1;
}
@@ -1204,12 +1208,18 @@ static int apply_batch(int xc_handle, ui
/* a bogus/unmapped page: skip it */
continue;
+ if (pfn_err[i])
+ {
+ ERROR("unexpected PFN mapping failure");
+ goto err_mapped;
+ }
+
++curpage;
if ( pfn > dinfo->p2m_size )
{
ERROR("pfn out of range");
- return -1;
+ goto err_mapped;
}
pfn_type[pfn] = pagetype;
@@ -1257,7 +1267,7 @@ static int apply_batch(int xc_handle, ui
{
ERROR("Bogus page type %lx page table is out of range: "
"i=%d p2m_size=%lu", pagetype, i, dinfo->p2m_size);
- return -1;
+ goto err_mapped;
}
if ( pagebuf->verify )
@@ -1288,13 +1298,17 @@ static int apply_batch(int xc_handle, ui
| MMU_MACHPHYS_UPDATE, pfn) )
{
ERROR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn);
- return -1;
+ goto err_mapped;
}
} /* end of 'batch' for loop */
+ rc = nraces;
+
+ err_mapped:
munmap(region_base, j*PAGE_SIZE);
-
- return nraces;
+ free(pfn_err);
+
+ return rc;
}
int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|