diff --git a/criu/cr-dump.c b/criu/cr-dump.c index bbb265005..7c9270110 100644 --- a/criu/cr-dump.c +++ b/criu/cr-dump.c @@ -822,6 +822,29 @@ static int predump_criu_ns_ids(void) return predump_task_ns_ids(&crt.i); } +static int set_top_pid_ns(void) +{ + struct ns_id *ns; + + for (ns = ns_ids; ns != NULL; ns = ns->next) { + if (ns->nd != &pid_ns_desc) + continue; + if (ns->type == NS_ROOT) { + top_pid_ns = ns; + break; + } + if (ns->type == NS_CRIU) + top_pid_ns = ns; + } + + if (!top_pid_ns) { + pr_err("Can't set top_pid_ns\n"); + return -1; + } + + return 0; +} + static int collect_pstree_ids_predump() { struct pstree_item *item; @@ -834,7 +857,7 @@ static int collect_pstree_ids_predump() return -1; } - return 0; + return set_top_pid_ns(); } int collect_pstree_ids(void) @@ -845,7 +868,7 @@ int collect_pstree_ids(void) if (get_task_ids(item)) return -1; - return 0; + return set_top_pid_ns(); } static int collect_file_locks(void) diff --git a/criu/namespaces.c b/criu/namespaces.c index d41126215..5b0b3117a 100644 --- a/criu/namespaces.c +++ b/criu/namespaces.c @@ -448,11 +448,8 @@ static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd if (nd == &net_ns_desc) { INIT_LIST_HEAD(&nsid->net.ids); INIT_LIST_HEAD(&nsid->net.links); - } else if (nd == &pid_ns_desc) { + } else if (nd == &pid_ns_desc) nsid->pid.rb_root = RB_ROOT; - if (type == NS_ROOT || (type == NS_CRIU && !top_pid_ns)) - top_pid_ns = nsid; - } found: if (ns_ret) *ns_ret = nsid;