[CRIU] [PATCH 4/5] cr-restore: open pages-*.img FD as late as possible

Adrian Reber adrian at lisas.de
Tue Aug 21 11:20:48 EDT 2012


If reading the checkpoint images over a network socket the pages-*.img
FD has to be opened later after all other checkpoint images have been
read. Therefore moving the open() of pages-*.img just before jumping
to restorer.c.

Signed-off-by: Adrian Reber <adrian at lisas.de>
---
 cr-restore.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 65f698b..8fe1d75 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1160,7 +1160,6 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 	struct thread_restore_args *thread_args;
 
 	LIST_HEAD(self_vma_list);
-	int fd_pages = -1;
 	int i;
 
 	pr_info("Restore via sigreturn\n");
@@ -1184,12 +1183,6 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 	BUILD_BUG_ON(SHMEMS_SIZE % PAGE_SIZE);
 	BUILD_BUG_ON(TASK_ENTRIES_SIZE % PAGE_SIZE);
 
-	fd_pages = open_image_ro(CR_FD_PAGES, pid);
-	if (fd_pages < 0) {
-		pr_perror("Can't open pages-%d", pid);
-		goto err;
-	}
-
 	restore_code_len	= sizeof(restorer_blob);
 	restore_code_len	= round_up(restore_code_len, 16);
 
@@ -1304,7 +1297,6 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 	task_args->pid		= pid;
 	task_args->logfd	= log_get_fd();
 	task_args->sigchld_act	= sigchld_act;
-	task_args->fd_pages	= fd_pages;
 
 	strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
 
@@ -1383,6 +1375,12 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
 
 	}
 
+	task_args->fd_pages = open_image_ro(CR_FD_PAGES, pid);
+	if (task_args->fd_pages < 0) {
+		pr_perror("Can't open pages-%d", pid);
+		goto err;
+	}
+
 	close_image_dir();
 
 	pr_info("task_args: %p\n"
-- 
1.7.6.5



More information about the CRIU mailing list