[CRIU] [PATCH v2 17/21] fork: Move ns-specific code to setup_child_task_namespaces()
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 31 10:54:32 PDT 2017
No functional changes -- just to improve readability.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/cr-restore.c | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index cac963dce..70d369ada 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -459,6 +459,32 @@ static int set_pid_ns_for_children(struct ns_id *pid_ns, struct pid *pid)
return ret;
}
+static int setup_child_task_namespaces(struct pstree_item *item, struct ns_id **ret_pid_ns)
+{
+ struct ns_id *pid_ns;
+
+ pid_ns = lookup_ns_by_id(item->ids->pid_ns_id, &pid_ns_desc);
+ BUG_ON(!pid_ns);
+ item->pid_for_children_ns = pid_ns;
+
+ if (item != root_item) {
+ if (last_level_pid(item->pid) == INIT_PID)
+ item->user_ns = pid_ns->user_ns;
+ else
+ item->user_ns = current->user_ns;
+ } else
+ item->user_ns = root_user_ns;
+
+ wait_pid_ns_helper_prepared(pid_ns, item->pid);
+
+ if (set_pid_ns_for_children(pid_ns, item->pid) < 0)
+ return -1;
+
+ *ret_pid_ns = pid_ns;
+
+ return 0;
+}
+
static rt_sigaction_t sigchld_act;
/*
* If parent's sigaction has blocked SIGKILL (which is non-sence),
@@ -1330,18 +1356,6 @@ static inline int fork_with_pid(struct pstree_item *item)
pid_t pid = vpid(item);
struct ns_id *pid_ns;
- pid_ns = lookup_ns_by_id(item->ids->pid_ns_id, &pid_ns_desc);
- BUG_ON(!pid_ns);
- item->pid_for_children_ns = pid_ns;
-
- if (item != root_item) {
- if (last_level_pid(item->pid) == INIT_PID)
- item->user_ns = pid_ns->user_ns;
- else
- item->user_ns = current->user_ns;
- } else
- item->user_ns = root_user_ns;
-
if (item->pid->state != TASK_HELPER) {
if (open_core(pid, &ca.core))
return -1;
@@ -1380,9 +1394,7 @@ static inline int fork_with_pid(struct pstree_item *item)
pr_info("Forking task with %d pid (flags 0x%lx)\n", pid, ca.clone_flags);
- wait_pid_ns_helper_prepared(pid_ns, item->pid);
-
- if (set_pid_ns_for_children(pid_ns, item->pid) < 0)
+ if (setup_child_task_namespaces(item, &pid_ns))
goto err;
lock_last_pid();
More information about the CRIU
mailing list