aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenpaging
diff options
context:
space:
mode:
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>2011-12-01 18:14:24 +0000
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>2011-12-01 18:14:24 +0000
commit30cc607d39add0e588698fb1af2762d161fb3cb5 (patch)
tree4e3c45100e670b9a3906282ae8f9cffa6a4e9a42 /tools/xenpaging
parent49aabd5cf18258967eb424bc3c1d212372deb796 (diff)
downloadxen-30cc607d39add0e588698fb1af2762d161fb3cb5.tar.gz
xen-30cc607d39add0e588698fb1af2762d161fb3cb5.tar.bz2
xen-30cc607d39add0e588698fb1af2762d161fb3cb5.zip
Teach xenpaging to use the new and non-racy xc_mem_paging_load interface
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Acked-by: Olaf Hering <olaf@aepfle.de> Committed-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'tools/xenpaging')
-rw-r--r--tools/xenpaging/xenpaging.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c
index 601d28c800..5784d0b160 100644
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -45,6 +45,7 @@ static char *dom_path;
static char watch_token[16];
static char *filename;
static int interrupted;
+static void *paging_buffer = NULL;
static void unlink_pagefile(void)
{
@@ -438,6 +439,13 @@ static xenpaging_t *xenpaging_init(int argc, char *argv[])
goto err;
}
+ paging_buffer = init_page();
+ if ( !paging_buffer )
+ {
+ ERROR("Creating page aligned load buffer");
+ goto err;
+ }
+
return paging;
err:
@@ -649,10 +657,20 @@ static int xenpaging_populate_page(xenpaging_t *paging,
unsigned char oom = 0;
DPRINTF("populate_page < gfn %"PRI_xen_pfn" pageslot %d\n", gfn, i);
+
+ /* Read page */
+ ret = read_page(fd, paging_buffer, i);
+ if ( ret != 0 )
+ {
+ ERROR("Error reading page");
+ goto out;
+ }
+
do
{
/* Tell Xen to allocate a page for the domain */
- ret = xc_mem_paging_prep(xch, paging->mem_event.domain_id, gfn);
+ ret = xc_mem_paging_load(xch, paging->mem_event.domain_id, gfn,
+ paging_buffer);
if ( ret != 0 )
{
if ( errno == ENOMEM )
@@ -662,33 +680,14 @@ static int xenpaging_populate_page(xenpaging_t *paging,
sleep(1);
continue;
}
- PERROR("Error preparing %"PRI_xen_pfn" for page-in", gfn);
- goto out_map;
+ PERROR("Error loading %"PRI_xen_pfn" during page-in", gfn);
+ goto out;
}
}
while ( ret && !interrupted );
- /* Map page */
- ret = -EFAULT;
- page = xc_map_foreign_pages(xch, paging->mem_event.domain_id,
- PROT_READ | PROT_WRITE, &gfn, 1);
- if ( page == NULL )
- {
- PERROR("Error mapping page %"PRI_xen_pfn": page is null", gfn);
- goto out_map;
- }
-
- /* Read page */
- ret = read_page(fd, page, i);
- if ( ret != 0 )
- {
- PERROR("Error reading page %"PRI_xen_pfn"", gfn);
- goto out;
- }
out:
- munmap(page, PAGE_SIZE);
- out_map:
return ret;
}