From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Subject: [PATCH 09/21] xenpaging: allow negative num_pages and limit num_pages Date: Fri, 26 Nov 2010 14:49:10 +0100 Message-ID: <20101126134904.540164316@aepfle.de> References: <20101126134901.384130351@aepfle.de> Return-path: Content-Disposition: inline; filename=xen-unstable.xenpaging.num_pages_equal_max_pages.patch List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Simplify paging size argument. If a negative number is specified, it means the entire guest memory should be paged out. This is useful for debugging. Also limit num_pages to the guests max_pages. Signed-off-by: Olaf Hering --- tools/xenpaging/xenpaging.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- xen-unstable.hg-4.1.22433.orig/tools/xenpaging/xenpaging.c +++ xen-unstable.hg-4.1.22433/tools/xenpaging/xenpaging.c @@ -521,8 +521,6 @@ int main(int argc, char *argv[]) domain_id = atoi(argv[1]); num_pages = atoi(argv[2]); - victims = calloc(num_pages, sizeof(xenpaging_victim_t)); - /* Seed random-number generator */ srand(time(NULL)); @@ -543,6 +541,13 @@ int main(int argc, char *argv[]) return 2; } + if ( num_pages < 0 || num_pages > paging->domain_info->max_pages ) + { + num_pages = paging->domain_info->max_pages; + DPRINTF("setting num_pages to %d\n", num_pages); + } + victims = calloc(num_pages, sizeof(xenpaging_victim_t)); + /* ensure that if we get a signal, we'll do cleanup, then exit */ act.sa_handler = close_handler; act.sa_flags = 0;