mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
dump: Save pstree_item's parent on item, not ppid
This is trivial change, but is required to check for pgid/sid are in 'restorable' state, see for respective patch/code for details. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
28
cr-dump.c
28
cr-dump.c
@@ -1085,6 +1085,12 @@ static void pstree_switch_state(const struct list_head *list, int st)
|
|||||||
unseize_task_and_threads(item, st);
|
unseize_task_and_threads(item, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pid_t item_ppid(const struct pstree_item *item)
|
||||||
|
{
|
||||||
|
item = item->parent;
|
||||||
|
return item ? item->pid : -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int seize_threads(const struct pstree_item *item)
|
static int seize_threads(const struct pstree_item *item)
|
||||||
{
|
{
|
||||||
int i = 0, ret;
|
int i = 0, ret;
|
||||||
@@ -1099,7 +1105,7 @@ static int seize_threads(const struct pstree_item *item)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
pr_info("\tSeizing %d's %d thread\n", item->pid, item->threads[i]);
|
pr_info("\tSeizing %d's %d thread\n", item->pid, item->threads[i]);
|
||||||
ret = seize_task(item->threads[i], item->ppid);
|
ret = seize_task(item->threads[i], item_ppid(item));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@@ -1140,7 +1146,8 @@ static int collect_threads(struct pstree_item *item)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pstree_item *collect_task(pid_t pid, pid_t ppid, struct list_head *list)
|
static struct pstree_item *collect_task(pid_t pid, struct pstree_item *parent,
|
||||||
|
struct list_head *list)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct pstree_item *item;
|
struct pstree_item *item;
|
||||||
@@ -1149,13 +1156,14 @@ static struct pstree_item *collect_task(pid_t pid, pid_t ppid, struct list_head
|
|||||||
if (!item)
|
if (!item)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ret = seize_task(pid, ppid);
|
item->pid = pid;
|
||||||
|
item->parent = parent;
|
||||||
|
|
||||||
|
ret = seize_task(pid, item_ppid(item));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_free;
|
goto err_free;
|
||||||
|
|
||||||
pr_info("Seized task %d, state %d\n", pid, ret);
|
pr_info("Seized task %d, state %d\n", pid, ret);
|
||||||
item->pid = pid;
|
|
||||||
item->ppid = ppid;
|
|
||||||
item->state = ret;
|
item->state = ret;
|
||||||
|
|
||||||
ret = collect_threads(item);
|
ret = collect_threads(item);
|
||||||
@@ -1207,14 +1215,14 @@ static int check_subtree(const struct pstree_item *item)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int collect_subtree(pid_t pid, pid_t ppid, struct list_head *pstree_list,
|
static int collect_subtree(pid_t pid, struct pstree_item *parent,
|
||||||
int leader_only)
|
struct list_head *pstree_list, int leader_only)
|
||||||
{
|
{
|
||||||
struct pstree_item *item;
|
struct pstree_item *item;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pr_info("Collecting tasks starting from %d\n", pid);
|
pr_info("Collecting tasks starting from %d\n", pid);
|
||||||
item = collect_task(pid, ppid, pstree_list);
|
item = collect_task(pid, parent, pstree_list);
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -1222,7 +1230,7 @@ static int collect_subtree(pid_t pid, pid_t ppid, struct list_head *pstree_list,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < item->nr_children; i++)
|
for (i = 0; i < item->nr_children; i++)
|
||||||
if (collect_subtree(item->children[i], item->pid, pstree_list, 0) < 0)
|
if (collect_subtree(item->children[i], item, pstree_list, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (check_subtree(item))
|
if (check_subtree(item))
|
||||||
@@ -1241,7 +1249,7 @@ static int collect_dump_pstree(pid_t pid, struct list_head *pstree_list,
|
|||||||
while (1) {
|
while (1) {
|
||||||
struct pstree_item *item;
|
struct pstree_item *item;
|
||||||
|
|
||||||
ret = collect_subtree(pid, -1, pstree_list, opts->leader_only);
|
ret = collect_subtree(pid, NULL, pstree_list, opts->leader_only);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/*
|
/*
|
||||||
* Some tasks could have been reparented to
|
* Some tasks could have been reparented to
|
||||||
|
@@ -176,7 +176,7 @@ struct vma_area {
|
|||||||
struct pstree_item {
|
struct pstree_item {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
pid_t pid; /* leader pid */
|
pid_t pid; /* leader pid */
|
||||||
pid_t ppid;
|
struct pstree_item *parent;
|
||||||
int state; /* TASK_XXX constants */
|
int state; /* TASK_XXX constants */
|
||||||
int nr_children; /* number of children */
|
int nr_children; /* number of children */
|
||||||
int nr_threads; /* number of threads */
|
int nr_threads; /* number of threads */
|
||||||
|
Reference in New Issue
Block a user