mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
ns: Replace task argument rst_add_ns_id() with pid
We don't need task in that function, also this allows to delete fake task in read_ns_with_hookups(). Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
be38302ca2
commit
6b0b8d6483
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user