|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] xenpaging: move pagefile filedescriptor into struct xenpaging
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1329769124 -3600
# Node ID 58c5b8c9ad8a8be43c4c5fb8020d4578a49b7199
# Parent 80a9d3190b7c58a5d13017f770f1a5915288ec37
xenpaging: move pagefile filedescriptor into struct xenpaging
Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---
diff -r 80a9d3190b7c -r 58c5b8c9ad8a tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c Mon Feb 20 21:18:44 2012 +0100
+++ b/tools/xenpaging/xenpaging.c Mon Feb 20 21:18:44 2012 +0100
@@ -448,6 +448,14 @@
goto err;
}
+ /* Open file */
+ paging->fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
+ if ( paging->fd < 0 )
+ {
+ PERROR("failed to open file");
+ goto err;
+ }
+
return paging;
err:
@@ -562,7 +570,7 @@
* Returns 0 on successful evict
* Returns > 0 if gfn can not be evicted
*/
-static int xenpaging_evict_page(struct xenpaging *paging, unsigned long gfn,
int fd, int slot)
+static int xenpaging_evict_page(struct xenpaging *paging, unsigned long gfn,
int slot)
{
xc_interface *xch = paging->xc_handle;
void *page;
@@ -593,7 +601,7 @@
}
/* Copy page */
- ret = write_page(fd, page, slot);
+ ret = write_page(paging->fd, page, slot);
if ( ret < 0 )
{
PERROR("Error copying page %lx", gfn);
@@ -670,7 +678,7 @@
return ret;
}
-static int xenpaging_populate_page(struct xenpaging *paging, unsigned long
gfn, int fd, int i)
+static int xenpaging_populate_page(struct xenpaging *paging, unsigned long
gfn, int i)
{
xc_interface *xch = paging->xc_handle;
int ret;
@@ -679,7 +687,7 @@
DPRINTF("populate_page < gfn %lx pageslot %d\n", gfn, i);
/* Read page */
- ret = read_page(fd, paging_buffer, i);
+ ret = read_page(paging->fd, paging_buffer, i);
if ( ret != 0 )
{
PERROR("Error reading page");
@@ -738,7 +746,7 @@
* Returns 0 on successful evict
* Returns > 0 if no gfn can be evicted
*/
-static int evict_victim(struct xenpaging *paging, int fd, int slot)
+static int evict_victim(struct xenpaging *paging, int slot)
{
xc_interface *xch = paging->xc_handle;
unsigned long gfn;
@@ -771,7 +779,7 @@
goto out;
}
- ret = xenpaging_evict_page(paging, gfn, fd, slot);
+ ret = xenpaging_evict_page(paging, gfn, slot);
if ( ret < 0 )
goto out;
}
@@ -791,7 +799,7 @@
* Returns 0 if no gfn can be evicted
* Returns > 0 on successful evict
*/
-static int evict_pages(struct xenpaging *paging, int fd, int num_pages)
+static int evict_pages(struct xenpaging *paging, int num_pages)
{
xc_interface *xch = paging->xc_handle;
int rc, slot, num = 0;
@@ -802,7 +810,7 @@
if ( paging->slot_to_gfn[slot] )
continue;
- rc = evict_victim(paging, fd, slot);
+ rc = evict_victim(paging, slot);
if ( rc )
{
num = rc < 0 ? -1 : num;
@@ -826,10 +834,6 @@
int rc;
xc_interface *xch;
- int open_flags = O_CREAT | O_TRUNC | O_RDWR;
- mode_t open_mode = S_IRUSR | S_IWUSR;
- int fd;
-
/* Initialise domain paging */
paging = xenpaging_init(argc, argv);
if ( paging == NULL )
@@ -841,14 +845,6 @@
DPRINTF("starting %s for domain_id %u with pagefile %s\n", argv[0],
paging->mem_event.domain_id, filename);
- /* Open file */
- fd = open(filename, open_flags, open_mode);
- if ( fd < 0 )
- {
- perror("failed to open file");
- return 2;
- }
-
/* ensure that if we get a signal, we'll do cleanup, then exit */
act.sa_handler = close_handler;
act.sa_flags = 0;
@@ -911,7 +907,7 @@
else
{
/* Populate the page */
- if ( xenpaging_populate_page(paging, req.gfn, fd, slot) <
0 )
+ if ( xenpaging_populate_page(paging, req.gfn, slot) < 0 )
{
ERROR("Error populating page %"PRIx64"", req.gfn);
goto out;
@@ -1005,7 +1001,7 @@
paging->use_poll_timeout = 0;
num = 42;
}
- if ( evict_pages(paging, fd, num) < 0 )
+ if ( evict_pages(paging, num) < 0 )
goto out;
}
/* Resume some pages if target not reached */
@@ -1033,7 +1029,7 @@
DPRINTF("xenpaging got signal %d\n", interrupted);
out:
- close(fd);
+ close(paging->fd);
unlink_pagefile();
/* Tear down domain paging */
diff -r 80a9d3190b7c -r 58c5b8c9ad8a tools/xenpaging/xenpaging.h
--- a/tools/xenpaging/xenpaging.h Mon Feb 20 21:18:44 2012 +0100
+++ b/tools/xenpaging/xenpaging.h Mon Feb 20 21:18:44 2012 +0100
@@ -50,6 +50,7 @@
int *gfn_to_slot;
struct mem_event mem_event;
+ int fd;
/* number of pages for which data structures were allocated */
int max_pages;
int num_paged_out;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |