2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-02 15:25:21 +00:00

pstree: Dump threads pid_for_children_ns

It may differ from group leader's pid_for_children_ns,
so dump it separate.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2017-05-31 20:54:12 +03:00
committed by Andrei Vagin
parent e3e1d8afd7
commit 3dbe8541b1
4 changed files with 32 additions and 2 deletions

View File

@@ -679,6 +679,18 @@ err:
return -1; return -1;
} }
static int get_thread_ids(struct pstree_item *item, int id)
{
CoreEntry *core = item->core[id];
core->ids = xmalloc(sizeof(*core->ids));
if (!core->ids)
return -1;
task_kobj_ids_entry__init(core->ids);
return dump_thread_ids(item->threads[id]->real, core->ids);
}
static int do_dump_task_ids(const struct pstree_item *item, struct cr_img *img) static int do_dump_task_ids(const struct pstree_item *item, struct cr_img *img)
{ {
return pb_write_one(img, item->ids, PB_IDS); return pb_write_one(img, item->ids, PB_IDS);
@@ -863,10 +875,18 @@ static int collect_pstree_ids_predump()
int collect_pstree_ids(void) int collect_pstree_ids(void)
{ {
struct pstree_item *item; struct pstree_item *item;
int i;
for_each_pstree_item(item) for_each_pstree_item(item) {
if (get_task_ids(item)) if (get_task_ids(item))
return -1; return -1;
for (i = 0; i < item->nr_threads; i++) {
if (item->threads[i]->real == item->pid->real)
continue;
if (get_thread_ids(item, i))
return -1;
}
}
return set_top_pid_ns(); return set_top_pid_ns();
} }

View File

@@ -3540,7 +3540,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
blkset = (void *)&tcore->thread_core->blk_sigset; blkset = (void *)&tcore->thread_core->blk_sigset;
} }
if ((tcore->tc || tcore->ids) && thread_args[i].pid[0] != pid) { if ((tcore->tc) && thread_args[i].pid[0] != pid) {
pr_err("Thread has optional fields present %d\n", pr_err("Thread has optional fields present %d\n",
thread_args[i].pid[0]); thread_args[i].pid[0]);
ret = -1; ret = -1;

View File

@@ -7,6 +7,7 @@
#include "files.h" #include "files.h"
#include "common/list.h" #include "common/list.h"
#include "images/ns.pb-c.h" #include "images/ns.pb-c.h"
#include "images/core.pb-c.h"
#include "images/netdev.pb-c.h" #include "images/netdev.pb-c.h"
#ifndef CLONE_NEWNS #ifndef CLONE_NEWNS
@@ -200,6 +201,7 @@ extern int restore_ns(int rst, struct ns_desc *nd);
extern int dump_task_ns_ids(struct pstree_item *); extern int dump_task_ns_ids(struct pstree_item *);
extern int predump_task_ns_ids(struct pstree_item *); extern int predump_task_ns_ids(struct pstree_item *);
extern int dump_thread_ids(pid_t pid, TaskKobjIdsEntry *ids);
extern struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd, enum ns_type t); 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, pid_t pid, 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 struct ns_id *lookup_ns_by_id(unsigned int id, struct ns_desc *nd);

View File

@@ -800,6 +800,14 @@ int dump_task_ns_ids(struct pstree_item *item)
return 0; return 0;
} }
int dump_thread_ids(pid_t pid, TaskKobjIdsEntry *ids)
{
if (get_pid_for_children_ns_id(pid, ids) < 0)
return -1;
return 0;
}
static int set_ns_opt(int ns_fd, unsigned ioc, struct ns_id **ns, struct ns_desc *nd) static int set_ns_opt(int ns_fd, unsigned ioc, struct ns_id **ns, struct ns_desc *nd)
{ {
int opt_fd, ret = -1; int opt_fd, ret = -1;