[CRIU] [PATCH v2 30/57] pid: Implement populate_ns_pids() helper
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Mar 28 08:38:41 PDT 2017
Assign pids in separate function. Just a refactoring,
which will be used in next patches.
v2: Do not check for top_pid_ns->children, because
it's not populated. We will use kdat.has_nspid check
in next patches instead
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/cr-dump.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 5e4f2dfa..dd6884e7 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -586,6 +586,21 @@ static int get_task_personality(pid_t pid, u32 *personality)
return ret;
}
+static int populate_ns_pids(pid_t real_pid, pid_t real_tid,
+ struct pid **pid, struct pid **sid, struct pid **pgid,
+ pid_t parasite_pid, pid_t parasite_sid, pid_t parasite_pgid)
+{
+ if (1) {
+ (*pid)->ns[0].virt = parasite_pid;
+ if (real_tid < 0) {
+ (*sid)->ns[0].virt = parasite_sid;
+ (*pgid)->ns[0].virt = parasite_pgid;
+ }
+ return 0;
+ }
+ return 0;
+}
+
static DECLARE_KCMP_TREE(vm_tree, KCMP_VM);
static DECLARE_KCMP_TREE(fs_tree, KCMP_FS);
static DECLARE_KCMP_TREE(files_tree, KCMP_FILES);
@@ -841,8 +856,13 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl,
pr_err("Can't dump thread for pid %d\n", pid);
goto err;
}
- tid->ns[0].virt = parasite_tid;
+ if (populate_ns_pids(item->pid->real, tid->real, &tid, NULL, NULL,
+ parasite_tid, -1, -1) < 0) {
+ pr_err("Can't get ns pids\n");
+ goto err;
+ }
+ item->threads[id] = tid;
pstree_insert_pid(tid, item->ids->pid_ns_id);
img = open_image(CR_FD_CORE, O_DUMP, tid->ns[0].virt);
@@ -1181,7 +1201,11 @@ static int pre_dump_one_task(struct pstree_item *item)
goto err_cure;
}
- item->pid->ns[0].virt = misc.pid;
+ if (populate_ns_pids(pid, -1, &item->pid, &item->sid, &item->pgid,
+ misc.pid, misc.sid, misc.pgid) < 0) {
+ pr_err("Can't get ns pids\n");
+ goto err_cure;
+ }
mdc.pre_dump = true;
mdc.lazy = false;
@@ -1311,9 +1335,11 @@ static int dump_one_task(struct pstree_item *item)
goto err_cure_imgset;
}
- item->pid->ns[0].virt = misc.pid;
- item->sid->ns[0].virt = misc.sid;
- item->pgid->ns[0].virt = misc.pgid;
+ if (populate_ns_pids(pid, -1, &item->pid, &item->sid, &item->pgid,
+ misc.pid, misc.sid, misc.pgid) < 0) {
+ pr_err("Can't get ns pids\n");
+ goto err_cure_imgset;
+ }
pstree_insert_pid(item->pid, item->ids->pid_ns_id);
pr_info("sid=%d pgid=%d pid=%d\n",
More information about the CRIU
mailing list