[CRIU] [PATCH 1/2] dump: collect all pid-s in rbtree
Andrey Vagin
avagin at openvz.org
Mon May 9 17:54:08 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
We already do this on restore to be able to search tasks by their virtual PID-s.
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
criu/cr-dump.c | 2 ++
criu/include/pstree.h | 1 +
criu/proc_parse.c | 1 +
criu/pstree.c | 9 +++++++++
4 files changed, 13 insertions(+)
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 5ac9fd0..817fd74 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -828,6 +828,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl,
pr_err("Can't dump thread for pid %d\n", pid);
goto err;
}
+ pstree_insert_pid(tid->virt, tid);
img = open_image(CR_FD_CORE, O_DUMP, tid->virt);
if (!img)
@@ -1284,6 +1285,7 @@ static int dump_one_task(struct pstree_item *item)
}
parasite_ctl->pid.virt = item->pid.virt = misc.pid;
+ pstree_insert_pid(item->pid.virt, &item->pid);
item->sid = misc.sid;
item->pgid = misc.pgid;
diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 6ff8781..afefd67 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -67,6 +67,7 @@ extern struct pstree_item *__alloc_pstree_item(bool rst);
extern void init_pstree_helper(struct pstree_item *ret);
extern struct pstree_item *lookup_create_item(pid_t pid);
+extern void pstree_insert_pid(pid_t pid, struct pid *pid_node);
extern struct pstree_item *root_item;
extern struct pstree_item *pstree_item_next(struct pstree_item *item);
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index ec1a7f1..43cda0d 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -2145,6 +2145,7 @@ int parse_threads(int pid, struct pid **_t, int *_n)
t[nr - 1].virt = -1;
}
t[nr - 1].real = atoi(de->d_name);
+ t[nr - 1].state = TASK_THREAD;
nr++;
}
diff --git a/criu/pstree.c b/criu/pstree.c
index a03321e..7a30ab8 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -412,6 +412,15 @@ static struct pid *lookup_create_pid(pid_t pid, struct pid *pid_node)
return pid_node;
}
+void pstree_insert_pid(pid_t pid, struct pid *pid_node)
+{
+ struct pid* n;
+
+ n = lookup_create_pid(pid, pid_node);
+
+ BUG_ON(n != pid_node);
+}
+
struct pstree_item *lookup_create_item(pid_t pid)
{
struct pid *node;;
--
2.7.4
More information about the CRIU
mailing list