diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h index 05c08b52e..62fa091fb 100644 --- a/criu/include/namespaces.h +++ b/criu/include/namespaces.h @@ -160,7 +160,7 @@ extern int restore_ns(int rst, struct ns_desc *nd); extern int dump_task_ns_ids(struct pstree_item *); extern int predump_task_ns_ids(struct pstree_item *); extern struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd, enum ns_type t); -extern int rst_add_ns_id(unsigned int id, struct pstree_item *, struct ns_desc *nd); +extern int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd); extern struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd); extern int collect_user_namespaces(bool for_dump); diff --git a/criu/namespaces.c b/criu/namespaces.c index 31cd51d2f..43b7578a2 100644 --- a/criu/namespaces.c +++ b/criu/namespaces.c @@ -309,9 +309,8 @@ struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, return nsid; } -int rst_add_ns_id(unsigned int id, struct pstree_item *i, struct ns_desc *nd) +int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd) { - pid_t pid = vpid(i); struct ns_id *nsid; nsid = lookup_ns_by_id(id, nd); @@ -1858,15 +1857,10 @@ int read_ns_with_hookups(void) { struct ns_id *ns, *p_ns, *u_ns; struct delayed_ns *d_ns = NULL; - struct pstree_item fake; NsEntry *e = NULL; int ret = 0, nr_d = 0; struct ns_desc *desc; struct cr_img *img; - struct pid pid; - - pid.ns[0].virt = -1; - fake.pid = &pid; img = open_image(CR_FD_NS, O_RSTR); if (!img) @@ -1885,7 +1879,7 @@ int read_ns_with_hookups(void) else if (e->ns_cflag == CLONE_NEWNET) desc = &net_ns_desc; - if (rst_add_ns_id(e->id, &fake, desc)) { + if (rst_add_ns_id(e->id, -1, desc)) { pr_err("Can't add user ns\n"); goto close; } diff --git a/criu/pstree.c b/criu/pstree.c index 0edf519fb..01bd61bfc 100644 --- a/criu/pstree.c +++ b/criu/pstree.c @@ -463,6 +463,7 @@ struct pid *pstree_pid_by_virt(pid_t pid) static int read_pstree_ids(struct pstree_item *pi) { + pid_t pid = vpid(pi); int ret; struct cr_img *img; @@ -477,31 +478,31 @@ static int read_pstree_ids(struct pstree_item *pi) return ret; if (pi->ids->has_mnt_ns_id) { - if (rst_add_ns_id(pi->ids->mnt_ns_id, pi, &mnt_ns_desc)) + if (rst_add_ns_id(pi->ids->mnt_ns_id, pid, &mnt_ns_desc)) return -1; } if (pi->ids->has_net_ns_id) { - if (rst_add_ns_id(pi->ids->net_ns_id, pi, &net_ns_desc)) + if (rst_add_ns_id(pi->ids->net_ns_id, pid, &net_ns_desc)) return -1; } if (pi->ids->has_user_ns_id) { - if (rst_add_ns_id(pi->ids->user_ns_id, pi, &user_ns_desc)) + if (rst_add_ns_id(pi->ids->user_ns_id, pid, &user_ns_desc)) return -1; } if (pi->ids->has_pid_ns_id) { - if (rst_add_ns_id(pi->ids->pid_ns_id, pi, &pid_ns_desc)) + if (rst_add_ns_id(pi->ids->pid_ns_id, pid, &pid_ns_desc)) return -1; } if (pi->ids->has_ipc_ns_id) { - if (rst_add_ns_id(pi->ids->ipc_ns_id, pi, &ipc_ns_desc)) + if (rst_add_ns_id(pi->ids->ipc_ns_id, pid, &ipc_ns_desc)) return -1; } if (pi->ids->has_uts_ns_id) { - if (rst_add_ns_id(pi->ids->uts_ns_id, pi, &uts_ns_desc)) + if (rst_add_ns_id(pi->ids->uts_ns_id, pid, &uts_ns_desc)) return -1; } if (pi->ids->has_cgroup_ns_id) { - if (rst_add_ns_id(pi->ids->cgroup_ns_id, pi, &cgroup_ns_desc)) + if (rst_add_ns_id(pi->ids->cgroup_ns_id, pid, &cgroup_ns_desc)) return -1; }