From: Keir Fraser Date: Fri, 26 Nov 2010 14:15:59 +0000 (+0000) Subject: xenpaging: Open paging file only if xenpaging_init() succeeds X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11208 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=baed2852e7681f39d1135479fa987bffe19fde6d;p=xen.git xenpaging: Open paging file only if xenpaging_init() succeeds Open paging file only if xenpaging_init() succeeds. It can fail if the host does not support the required virtualization features such as EPT or if xenpaging was already started for this domain_id. Signed-off-by: Olaf Hering Already-Acked-by: Patrick Colp Already-Acked-by: Keir Fraser --- diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index 778537bd5c..64e265c405 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -502,15 +502,6 @@ int main(int argc, char *argv[]) victims = calloc(num_pages, sizeof(xenpaging_victim_t)); - /* Open file */ - sprintf(filename, "page_cache_%d", domain_id); - fd = open(filename, open_flags, open_mode); - if ( fd < 0 ) - { - perror("failed to open file"); - return -1; - } - /* Seed random-number generator */ srand(time(NULL)); @@ -522,6 +513,15 @@ int main(int argc, char *argv[]) goto out; } + /* Open file */ + sprintf(filename, "page_cache_%d", domain_id); + fd = open(filename, open_flags, open_mode); + if ( fd < 0 ) + { + perror("failed to open file"); + return -1; + } + /* Evict pages */ memset(victims, 0, sizeof(xenpaging_victim_t) * num_pages); for ( i = 0; i < num_pages; i++ )