[15/15] restore: Move uffd setup out of sigreturn_restore

Submitted by Pavel Emelianov on May 24, 2016, 11:37 a.m.

Details

Message ID 57443CEE.9050704@virtuozzo.com
State Superseded
Commit e42a93d13f9a060c0e3ed44efac5dbe06141cdfb
Headers show

Commit Message

Pavel Emelianov May 24, 2016, 11:37 a.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/cr-restore.c   | 9 +++------
 criu/include/uffd.h | 2 +-
 criu/uffd.c         | 8 +++++++-
 3 files changed, 11 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index cfa1c4e..033119a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -560,6 +560,9 @@  static int restore_one_alive_task(int pid, CoreEntry *core)
 	if (prepare_mm(pid, ta))
 		return -1;
 
+	if (setup_uffd(pid, ta))
+		return -1;
+
 	return sigreturn_restore(pid, ta_cp, core);
 }
 
@@ -2891,12 +2894,6 @@  static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
 
 	strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
 
-	if (!opts.lazy_pages)
-		task_args->uffd = -1;
-	else
-		if (setup_uffd(task_args, pid) != 0)
-			goto err;
-
 	/*
 	 * Fill up per-thread data.
 	 */
diff --git a/criu/include/uffd.h b/criu/include/uffd.h
index 4e1ba4a..66ce459 100644
--- a/criu/include/uffd.h
+++ b/criu/include/uffd.h
@@ -2,6 +2,6 @@ 
 #define __CR_UFFD_H_
 
 struct task_restore_args;
-extern int setup_uffd(struct task_restore_args *task_args, int pid);
+extern int setup_uffd(int pid, struct task_restore_args *task_args);
 
 #endif /* __CR_UFFD_H_ */
diff --git a/criu/uffd.c b/criu/uffd.c
index c7c7d6b..4e9d46a 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -183,9 +183,15 @@  static int check_for_uffd()
 }
 
 /* This function is used by 'criu restore --lazy-pages' */
-int setup_uffd(struct task_restore_args *task_args, int pid)
+int setup_uffd(int pid, struct task_restore_args *task_args)
 {
 	struct uffdio_api uffdio_api;
+
+	if (!opts.lazy_pages) {
+		task_args->uffd = -1;
+		return 0;
+	}
+
 	if (check_for_uffd())
 		return -1;
 	/*