[CRIU] [PATCH 07/15] restore: Prepare on-restorer timerfds earlier

Pavel Emelyanov xemul at virtuozzo.com
Tue May 24 04:35:21 PDT 2016


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c      | 15 +++++++--------
 criu/include/timerfd.h |  6 ++----
 criu/timerfd.c         | 11 +++++------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index c95d049..6039688 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -545,6 +545,12 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
 	if (prepare_tcp_socks(ta))
 		return -1;
 
+	/*
+	 * Copy timerfd params for restorer args, we need to proceed
+	 * timer setting at the very late.
+	 */
+	if (prepare_timerfds(ta))
+		return -1;
 
 	return sigreturn_restore(pid, ta_cp, core);
 }
@@ -2733,13 +2739,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
 	BUILD_BUG_ON(sizeof(struct thread_restore_args) & 1);
 
 	/*
-	 * Copy timerfd params for restorer args, we need to proceed
-	 * timer setting at the very late.
-	 */
-	if (rst_timerfd_prep())
-		goto err_nv;
-
-	/*
 	 * Read creds info for every thread and allocate memory
 	 * needed so we can use this data inside restorer.
 	 */
@@ -2868,6 +2867,7 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
 	task_args->vmas = rst_mem_remap_ptr((unsigned long)task_args->vmas, RM_PRIVATE);
 	task_args->rings = rst_mem_remap_ptr((unsigned long)task_args->rings, RM_PRIVATE);
 	task_args->tcp_socks = rst_mem_remap_ptr((unsigned long)task_args->tcp_socks, RM_PRIVATE);
+	task_args->timerfd = rst_mem_remap_ptr((unsigned long)task_args->timerfd, RM_PRIVATE);
 
 #define remap_array(name, nr, cpos)	do {				\
 		task_args->name##_n = nr;				\
@@ -2875,7 +2875,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
 	} while (0)
 
 	remap_array(posix_timers, posix_timers_nr, posix_timers_cpos);
-	remap_array(timerfd,	  rst_timerfd_nr, rst_timerfd_cpos);
 	remap_array(siginfo,	  siginfo_nr, siginfo_cpos);
 	remap_array(rlims,	  rlims_nr, rlims_cpos);
 	remap_array(helpers,	  n_helpers, helpers_pos);
diff --git a/criu/include/timerfd.h b/criu/include/timerfd.h
index 67b9187..9a7829f 100644
--- a/criu/include/timerfd.h
+++ b/criu/include/timerfd.h
@@ -20,10 +20,8 @@ struct restore_timerfd {
 extern const struct fdtype_ops timerfd_dump_ops;
 extern struct collect_image_info timerfd_cinfo;
 
-int rst_timerfd_prep(void);
-extern unsigned long rst_timerfd_cpos;
-extern unsigned int rst_timerfd_nr;
-
+struct task_restore_args;
+int prepare_timerfds(struct task_restore_args *);
 
 extern int check_timerfd(void);
 extern int is_timerfd_link(char *link);
diff --git a/criu/timerfd.c b/criu/timerfd.c
index c291516..55f7b85 100644
--- a/criu/timerfd.c
+++ b/criu/timerfd.c
@@ -37,9 +37,6 @@ struct timerfd_info {
 
 static LIST_HEAD(rst_timerfds);
 
-unsigned long rst_timerfd_cpos;
-unsigned int rst_timerfd_nr = 0;
-
 int check_timerfd(void)
 {
 	int fd, ret = -1;
@@ -110,12 +107,14 @@ static int timerfd_post_open(struct file_desc *d, int fd)
 	return 0;
 }
 
-int rst_timerfd_prep(void)
+int prepare_timerfds(struct task_restore_args *ta)
 {
 	struct timerfd_info *ti;
 	struct restore_timerfd *t;
 
-	rst_timerfd_cpos = rst_mem_align_cpos(RM_PRIVATE);
+	ta->timerfd = (struct restore_timerfd *)rst_mem_align_cpos(RM_PRIVATE);
+	ta->timerfd_n = 0;
+
 	list_for_each_entry(ti, &rst_timerfds, rlist) {
 		TimerfdEntry *tfe = ti->tfe;
 
@@ -133,7 +132,7 @@ int rst_timerfd_prep(void)
 		t->val.it_value.tv_sec		= (time_t)tfe->vsec;
 		t->val.it_value.tv_nsec		= (long)tfe->vnsec;
 
-		rst_timerfd_nr++;
+		ta->timerfd_n++;
 	}
 
 	return 0;
-- 
2.5.0



More information about the CRIU mailing list