mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 11:04:35 +00:00
dump: More obvious assignment of top_pid_ns
Currently it's set in generate_ns_id() and it's equal to: 1)NS_CRIU, if root_ns_mask does not contain CLONE_NEWPID, 2)NS_ROOT, if it contains. The assignment is not obvious, as it's set NS_CRIU firstly, and then rewrites in NS_ROOT, if it exists. Mark top_pid_ns after ns_ids population in more clear way. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
c204fb101e
commit
6f4a4e1bbd
2 changed files with 26 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue