Commit 8075dc60 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

pstree: rename fields in struct pid

s/pid/virt/
s/real_pid/real/
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9b3b059b
...@@ -792,7 +792,7 @@ static int parse_threads(const struct pstree_item *item, struct pid **_t, int *_ ...@@ -792,7 +792,7 @@ static int parse_threads(const struct pstree_item *item, struct pid **_t, int *_
struct pid *t = NULL; struct pid *t = NULL;
int nr = 1; int nr = 1;
dir = opendir_proc(item->pid.real_pid, "task"); dir = opendir_proc(item->pid.real, "task");
if (!dir) if (!dir)
return -1; return -1;
...@@ -809,8 +809,8 @@ static int parse_threads(const struct pstree_item *item, struct pid **_t, int *_ ...@@ -809,8 +809,8 @@ static int parse_threads(const struct pstree_item *item, struct pid **_t, int *_
return -1; return -1;
} }
t = tmp; t = tmp;
t[nr - 1].real_pid = atoi(de->d_name); t[nr - 1].real = atoi(de->d_name);
t[nr - 1].pid = -1; t[nr - 1].virt = -1;
nr++; nr++;
} }
...@@ -855,8 +855,8 @@ static int parse_children(const struct pstree_item *item, u32 **_c, int *_n) ...@@ -855,8 +855,8 @@ static int parse_children(const struct pstree_item *item, u32 **_c, int *_n)
int nr = 1, i; int nr = 1, i;
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
file = fopen_proc(item->pid.real_pid, "task/%d/children", file = fopen_proc(item->pid.real, "task/%d/children",
item->threads[i].real_pid); item->threads[i].real);
if (!file) if (!file)
goto err; goto err;
...@@ -899,8 +899,8 @@ struct pstree_item *__alloc_pstree_item(bool rst) ...@@ -899,8 +899,8 @@ struct pstree_item *__alloc_pstree_item(bool rst)
INIT_LIST_HEAD(&item->children); INIT_LIST_HEAD(&item->children);
item->threads = NULL; item->threads = NULL;
item->nr_threads = 0; item->nr_threads = 0;
item->pid.pid = -1; item->pid.virt = -1;
item->pid.real_pid = -1; item->pid.real = -1;
return item; return item;
} }
...@@ -921,7 +921,7 @@ static int get_children(struct pstree_item *item) ...@@ -921,7 +921,7 @@ static int get_children(struct pstree_item *item)
ret = -1; ret = -1;
goto free; goto free;
} }
c->pid.real_pid = ch[i]; c->pid.real = ch[i];
c->parent = item; c->parent = item;
list_add_tail(&c->list, &item->children); list_add_tail(&c->list, &item->children);
} }
...@@ -935,7 +935,7 @@ static void unseize_task_and_threads(const struct pstree_item *item, int st) ...@@ -935,7 +935,7 @@ static void unseize_task_and_threads(const struct pstree_item *item, int st)
int i; int i;
for (i = 0; i < item->nr_threads; i++) for (i = 0; i < item->nr_threads; i++)
unseize_task(item->threads[i].real_pid, st); /* item->pid will be here */ unseize_task(item->threads[i].real, st); /* item->pid will be here */
} }
struct pstree_item *pstree_item_next(struct pstree_item *item) struct pstree_item *pstree_item_next(struct pstree_item *item)
...@@ -974,7 +974,7 @@ static void pstree_switch_state(struct pstree_item *root_item, int st) ...@@ -974,7 +974,7 @@ static void pstree_switch_state(struct pstree_item *root_item, int st)
static pid_t item_ppid(const struct pstree_item *item) static pid_t item_ppid(const struct pstree_item *item)
{ {
item = item->parent; item = item->parent;
return item ? item->pid.real_pid : -1; return item ? item->pid.real : -1;
} }
static int seize_threads(const struct pstree_item *item) static int seize_threads(const struct pstree_item *item)
...@@ -987,12 +987,12 @@ static int seize_threads(const struct pstree_item *item) ...@@ -987,12 +987,12 @@ static int seize_threads(const struct pstree_item *item)
} }
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
pid_t pid = item->threads[i].real_pid; pid_t pid = item->threads[i].real;
if (item->pid.real_pid == pid) if (item->pid.real == pid)
continue; continue;
pr_info("\tSeizing %d's %d thread\n", pr_info("\tSeizing %d's %d thread\n",
item->pid.real_pid, pid); item->pid.real, pid);
ret = seize_task(pid, item_ppid(item), NULL, NULL); ret = seize_task(pid, item_ppid(item), NULL, NULL);
if (ret < 0) if (ret < 0)
goto err; goto err;
...@@ -1012,10 +1012,10 @@ static int seize_threads(const struct pstree_item *item) ...@@ -1012,10 +1012,10 @@ static int seize_threads(const struct pstree_item *item)
err: err:
for (i--; i >= 0; i--) { for (i--; i >= 0; i--) {
if (item->pid.real_pid == item->threads[i].real_pid) if (item->pid.real == item->threads[i].real)
continue; continue;
unseize_task(item->threads[i].real_pid, TASK_ALIVE); unseize_task(item->threads[i].real, TASK_ALIVE);
} }
return -1; return -1;
...@@ -1067,20 +1067,20 @@ static int check_xids(struct pstree_item *root_item) ...@@ -1067,20 +1067,20 @@ static int check_xids(struct pstree_item *root_item)
continue; continue;
/* Easing #1 and #2 for sids */ /* Easing #1 and #2 for sids */
if ((p->sid != p->pid.pid) && (p->sid != p->parent->sid)) { if ((p->sid != p->pid.virt) && (p->sid != p->parent->sid)) {
pr_err("SID mismatch on %d (%d/%d)\n", pr_err("SID mismatch on %d (%d/%d)\n",
p->pid.pid, p->sid, p->parent->sid); p->pid.virt, p->sid, p->parent->sid);
return -1; return -1;
} }
/* Easing #2 for pgids */ /* Easing #2 for pgids */
for_each_pstree_item(tmp) for_each_pstree_item(tmp)
if (tmp->pid.pid == p->pgid) if (tmp->pid.virt == p->pgid)
break; break;
if (tmp == NULL) { if (tmp == NULL) {
pr_err("PGIG mismatch on %d (%d)\n", pr_err("PGIG mismatch on %d (%d)\n",
p->pid.pid, p->pgid); p->pid.virt, p->pgid);
return -1; return -1;
} }
} }
...@@ -1091,7 +1091,7 @@ static int check_xids(struct pstree_item *root_item) ...@@ -1091,7 +1091,7 @@ static int check_xids(struct pstree_item *root_item)
static int collect_task(struct pstree_item *item) static int collect_task(struct pstree_item *item)
{ {
int ret; int ret;
pid_t pid = item->pid.real_pid; pid_t pid = item->pid.real;
ret = seize_task(pid, item_ppid(item), &item->pgid, &item->sid); ret = seize_task(pid, item_ppid(item), &item->pgid, &item->sid);
if (ret < 0) if (ret < 0)
...@@ -1115,7 +1115,7 @@ static int collect_task(struct pstree_item *item) ...@@ -1115,7 +1115,7 @@ static int collect_task(struct pstree_item *item)
close_pid_proc(); close_pid_proc();
pr_info("Collected %d in %d state\n", item->pid.real_pid, item->state); pr_info("Collected %d in %d state\n", item->pid.real, item->state);
return 0; return 0;
err_close: err_close:
...@@ -1137,7 +1137,7 @@ static int check_subtree(const struct pstree_item *item) ...@@ -1137,7 +1137,7 @@ static int check_subtree(const struct pstree_item *item)
i = 0; i = 0;
list_for_each_entry(child, &item->children, list) { list_for_each_entry(child, &item->children, list) {
if (child->pid.real_pid != ch[i]) if (child->pid.real != ch[i])
break; break;
i++; i++;
if (i > nr) if (i > nr)
...@@ -1156,7 +1156,7 @@ static int check_subtree(const struct pstree_item *item) ...@@ -1156,7 +1156,7 @@ static int check_subtree(const struct pstree_item *item)
static int collect_subtree(struct pstree_item *item, int leader_only) static int collect_subtree(struct pstree_item *item, int leader_only)
{ {
struct pstree_item *child; struct pstree_item *child;
pid_t pid = item->pid.real_pid; pid_t pid = item->pid.real;
int ret; int ret;
pr_info("Collecting tasks starting from %d\n", pid); pr_info("Collecting tasks starting from %d\n", pid);
...@@ -1188,7 +1188,7 @@ static int collect_pstree(pid_t pid, const struct cr_options *opts) ...@@ -1188,7 +1188,7 @@ static int collect_pstree(pid_t pid, const struct cr_options *opts)
if (root_item == NULL) if (root_item == NULL)
return -1; return -1;
root_item->pid.real_pid = pid; root_item->pid.real = pid;
INIT_LIST_HEAD(&root_item->list); INIT_LIST_HEAD(&root_item->list);
ret = collect_subtree(root_item, opts->leader_only); ret = collect_subtree(root_item, opts->leader_only);
...@@ -1232,7 +1232,7 @@ static int dump_pstree(struct pstree_item *root_item) ...@@ -1232,7 +1232,7 @@ static int dump_pstree(struct pstree_item *root_item)
int pstree_fd; int pstree_fd;
pr_info("\n"); pr_info("\n");
pr_info("Dumping pstree (pid: %d)\n", root_item->pid.real_pid); pr_info("Dumping pstree (pid: %d)\n", root_item->pid.real);
pr_info("----------------------------------------\n"); pr_info("----------------------------------------\n");
ret = check_xids(root_item); ret = check_xids(root_item);
...@@ -1244,10 +1244,10 @@ static int dump_pstree(struct pstree_item *root_item) ...@@ -1244,10 +1244,10 @@ static int dump_pstree(struct pstree_item *root_item)
return -1; return -1;
for_each_pstree_item(item) { for_each_pstree_item(item) {
pr_info("Process: %d(%d)\n", item->pid.pid, item->pid.real_pid); pr_info("Process: %d(%d)\n", item->pid.virt, item->pid.real);
e.pid = item->pid.pid; e.pid = item->pid.virt;
e.ppid = item->parent ? item->parent->pid.pid : 0; e.ppid = item->parent ? item->parent->pid.virt : 0;
e.pgid = item->pgid; e.pgid = item->pgid;
e.sid = item->sid; e.sid = item->sid;
e.nr_threads = item->nr_threads; e.nr_threads = item->nr_threads;
...@@ -1257,7 +1257,7 @@ static int dump_pstree(struct pstree_item *root_item) ...@@ -1257,7 +1257,7 @@ static int dump_pstree(struct pstree_item *root_item)
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
if (write_img_buf(pstree_fd, if (write_img_buf(pstree_fd,
&item->threads[i].pid, sizeof(u32))) &item->threads[i].virt, sizeof(u32)))
goto err; goto err;
} }
} }
...@@ -1274,7 +1274,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1274,7 +1274,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
struct core_entry *core; struct core_entry *core;
int ret = -1, fd_core; int ret = -1, fd_core;
unsigned int *taddr; unsigned int *taddr;
pid_t pid = tid->real_pid; pid_t pid = tid->real;
pr_info("\n"); pr_info("\n");
pr_info("Dumping core for thread (pid: %d)\n", pid); pr_info("Dumping core for thread (pid: %d)\n", pid);
...@@ -1288,7 +1288,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1288,7 +1288,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
if (ret) if (ret)
goto err_free; goto err_free;
ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr, &tid->pid); ret = parasite_dump_thread_seized(parasite_ctl, pid, &taddr, &tid->virt);
if (ret) { if (ret) {
pr_err("Can't dump tid address for pid %d", pid); pr_err("Can't dump tid address for pid %d", pid);
goto err_free; goto err_free;
...@@ -1302,7 +1302,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid) ...@@ -1302,7 +1302,7 @@ static int dump_task_thread(struct parasite_ctl *parasite_ctl, struct pid *tid)
core->tc.task_state = TASK_ALIVE; core->tc.task_state = TASK_ALIVE;
core->tc.exit_code = 0; core->tc.exit_code = 0;
fd_core = open_image(CR_FD_CORE, O_DUMP, tid->pid); fd_core = open_image(CR_FD_CORE, O_DUMP, tid->virt);
if (fd_core < 0) if (fd_core < 0)
goto err_free; goto err_free;
...@@ -1329,7 +1329,7 @@ static int dump_one_zombie(const struct pstree_item *item, ...@@ -1329,7 +1329,7 @@ static int dump_one_zombie(const struct pstree_item *item,
core->tc.task_state = TASK_DEAD; core->tc.task_state = TASK_DEAD;
core->tc.exit_code = pps->exit_code; core->tc.exit_code = pps->exit_code;
fd_core = open_image(CR_FD_CORE, O_DUMP, item->pid.pid); fd_core = open_image(CR_FD_CORE, O_DUMP, item->pid);
if (fd_core < 0) if (fd_core < 0)
goto err_free; goto err_free;
...@@ -1350,8 +1350,8 @@ static int dump_task_threads(struct parasite_ctl *parasite_ctl, ...@@ -1350,8 +1350,8 @@ static int dump_task_threads(struct parasite_ctl *parasite_ctl,
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
/* Leader is already dumped */ /* Leader is already dumped */
if (item->pid.real_pid == item->threads[i].real_pid) { if (item->pid.real == item->threads[i].real) {
item->threads[i].pid = item->pid.pid; item->threads[i].virt = item->pid.virt;
continue; continue;
} }
...@@ -1364,7 +1364,7 @@ static int dump_task_threads(struct parasite_ctl *parasite_ctl, ...@@ -1364,7 +1364,7 @@ static int dump_task_threads(struct parasite_ctl *parasite_ctl,
static int dump_one_task(struct pstree_item *item) static int dump_one_task(struct pstree_item *item)
{ {
pid_t pid = item->pid.real_pid; pid_t pid = item->pid.real;
LIST_HEAD(vma_area_list); LIST_HEAD(vma_area_list);
struct parasite_ctl *parasite_ctl; struct parasite_ctl *parasite_ctl;
int ret = -1; int ret = -1;
...@@ -1394,12 +1394,12 @@ static int dump_one_task(struct pstree_item *item) ...@@ -1394,12 +1394,12 @@ static int dump_one_task(struct pstree_item *item)
if (item->state == TASK_DEAD) { if (item->state == TASK_DEAD) {
/* FIXME don't support zombie in pid name space*/ /* FIXME don't support zombie in pid name space*/
if (root_item->pid.pid == 1) { if (root_item->pid.virt == 1) {
pr_err("Can't dump a zombie %d in PIDNS", item->pid.real_pid); pr_err("Can't dump a zombie %d in PIDNS", item->pid.real);
ret = -1; ret = -1;
goto err; goto err;
} }
item->pid.pid = item->pid.real_pid; item->pid.virt = item->pid.real;
BUG_ON(!list_empty(&item->children)); BUG_ON(!list_empty(&item->children));
return dump_one_zombie(item, &pps_buf); return dump_one_zombie(item, &pps_buf);
...@@ -1430,12 +1430,12 @@ static int dump_one_task(struct pstree_item *item) ...@@ -1430,12 +1430,12 @@ static int dump_one_task(struct pstree_item *item)
goto err_cure_fdset; goto err_cure_fdset;
} }
item->pid.pid = misc.pid; item->pid.virt = misc.pid;
item->sid = misc.sid; item->sid = misc.sid;
item->pgid = misc.pgid; item->pgid = misc.pgid;
ret = -1; ret = -1;
cr_fdset = cr_task_fdset_open(item->pid.pid, O_DUMP); cr_fdset = cr_task_fdset_open(item->pid.virt, O_DUMP);
if (!cr_fdset) if (!cr_fdset)
goto err_cure; goto err_cure;
......
...@@ -100,7 +100,7 @@ static int prepare_pstree(void) ...@@ -100,7 +100,7 @@ static int prepare_pstree(void)
if (pi == NULL) if (pi == NULL)
break; break;
pi->pid.pid = e.pid; pi->pid.virt = e.pid;
pi->pgid = e.pgid; pi->pgid = e.pgid;
pi->sid = e.sid; pi->sid = e.sid;
...@@ -116,18 +116,18 @@ static int prepare_pstree(void) ...@@ -116,18 +116,18 @@ static int prepare_pstree(void)
* and sit among the last item's ancestors. * and sit among the last item's ancestors.
*/ */
while (parent) { while (parent) {
if (parent->pid.pid == e.ppid) if (parent->pid.virt == e.ppid)
break; break;
parent = parent->parent; parent = parent->parent;
} }
if (parent == NULL) if (parent == NULL)
for_each_pstree_item(parent) for_each_pstree_item(parent)
if (parent->pid.pid == e.ppid) if (parent->pid.virt == e.ppid)
break; break;
if (parent == NULL) { if (parent == NULL) {
pr_err("Can't find a parent for %d", pi->pid.pid); pr_err("Can't find a parent for %d", pi->pid.virt);
xfree(pi); xfree(pi);
break; break;
} }
...@@ -145,7 +145,7 @@ static int prepare_pstree(void) ...@@ -145,7 +145,7 @@ static int prepare_pstree(void)
ret = 0; ret = 0;
for (i = 0; i < e.nr_threads; i++) { for (i = 0; i < e.nr_threads; i++) {
ret = read_img_buf(ps_fd, &pi->threads[i].pid, sizeof(u32)); ret = read_img_buf(ps_fd, &pi->threads[i].virt, sizeof(u32));
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -201,11 +201,11 @@ static int prepare_shared(void) ...@@ -201,11 +201,11 @@ static int prepare_shared(void)
return -1; return -1;
for_each_pstree_item(pi) { for_each_pstree_item(pi) {
ret = prepare_shmem_pid(pi->pid.pid); ret = prepare_shmem_pid(pi->pid.virt);
if (ret < 0) if (ret < 0)
break; break;
ret = prepare_fd_pid(pi->pid.pid, pi->rst); ret = prepare_fd_pid(pi->pid.virt, pi->rst);
if (ret < 0) if (ret < 0)
break; break;
} }
...@@ -497,7 +497,7 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone ...@@ -497,7 +497,7 @@ static inline int fork_with_pid(struct pstree_item *item, unsigned long ns_clone
char buf[32]; char buf[32];
struct cr_clone_arg ca; struct cr_clone_arg ca;
void *stack; void *stack;
pid_t pid = item->pid.pid; pid_t pid = item->pid.virt;
pr_info("Forking task with %d pid (flags 0x%lx)\n", pid, ns_clone_flags); pr_info("Forking task with %d pid (flags 0x%lx)\n", pid, ns_clone_flags);
...@@ -581,8 +581,8 @@ static void restore_sid(void) ...@@ -581,8 +581,8 @@ static void restore_sid(void)
* we can call setpgid() on custom values. * we can call setpgid() on custom values.
*/ */
pr_info("Restoring %d to %d sid\n", me->pid.pid, me->sid); pr_info("Restoring %d to %d sid\n", me->pid.virt, me->sid);
if (me->pid.pid == me->sid) { if (me->pid.virt == me->sid) {
sid = setsid(); sid = setsid();
if (sid != me->sid) { if (sid != me->sid) {
pr_perror("Can't restore sid (%d)", sid); pr_perror("Can't restore sid (%d)", sid);
...@@ -602,7 +602,7 @@ static void restore_pgid(void) ...@@ -602,7 +602,7 @@ static void restore_pgid(void)
{ {
pid_t pgid; pid_t pgid;
pr_info("Restoring %d to %d pgid\n", me->pid.pid, me->pgid); pr_info("Restoring %d to %d pgid\n", me->pid.virt, me->pgid);
pgid = getpgrp(); pgid = getpgrp();
if (me->pgid == pgid) if (me->pgid == pgid)
...@@ -610,7 +610,7 @@ static void restore_pgid(void) ...@@ -610,7 +610,7 @@ static void restore_pgid(void)
pr_info("\twill call setpgid, mine pgid is %d\n", pgid); pr_info("\twill call setpgid, mine pgid is %d\n", pgid);
if (setpgid(0, me->pgid) != 0) { if (setpgid(0, me->pgid) != 0) {
pr_perror("Can't restore pgid (%d/%d->%d)", me->pid.pid, pgid, me->pgid); pr_perror("Can't restore pgid (%d/%d->%d)", me->pid.virt, pgid, me->pgid);
xid_fail(); xid_fail();
} }
} }
...@@ -630,8 +630,8 @@ static int restore_task_with_children(void *_arg) ...@@ -630,8 +630,8 @@ static int restore_task_with_children(void *_arg)
me = ca->item; me = ca->item;
pid = getpid(); pid = getpid();
if (me->pid.pid != pid) { if (me->pid.virt != pid) {
pr_err("Pid %d do not match expected %d\n", pid, me->pid.pid); pr_err("Pid %d do not match expected %d\n", pid, me->pid.virt);
exit(-1); exit(-1);
} }
...@@ -649,7 +649,7 @@ static int restore_task_with_children(void *_arg) ...@@ -649,7 +649,7 @@ static int restore_task_with_children(void *_arg)
exit(1); exit(1);
if (ca->clone_flags) { if (ca->clone_flags) {
ret = prepare_namespace(me->pid.pid, ca->clone_flags); ret = prepare_namespace(me->pid.virt, ca->clone_flags);
if (ret) if (ret)
exit(-1); exit(-1);
} }
...@@ -665,7 +665,7 @@ static int restore_task_with_children(void *_arg) ...@@ -665,7 +665,7 @@ static int restore_task_with_children(void *_arg)
sigdelset(&blockmask, SIGCHLD); sigdelset(&blockmask, SIGCHLD);
ret = sigprocmask(SIG_BLOCK, &blockmask, NULL); ret = sigprocmask(SIG_BLOCK, &blockmask, NULL);
if (ret) { if (ret) {
pr_perror("%d: Can't block signals", me->pid.pid); pr_perror("%d: Can't block signals", me->pid.virt);
exit(1); exit(1);
} }
...@@ -681,7 +681,7 @@ static int restore_task_with_children(void *_arg) ...@@ -681,7 +681,7 @@ static int restore_task_with_children(void *_arg)
restore_pgid(); restore_pgid();
return restore_one_task(me->pid.pid); return restore_one_task(me->pid.virt);
} }
static int restore_root_task(struct pstree_item *init, struct cr_options *opts) static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
...@@ -710,7 +710,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts) ...@@ -710,7 +710,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
* this later. * this later.
*/ */
if (init->pid.pid == 1) { if (init->pid.virt == 1) {
if (!(opts->namespaces_flags & CLONE_NEWPID)) { if (!(opts->namespaces_flags & CLONE_NEWPID)) {
pr_err("This process tree can be restored in a new pid namespace.\n"); pr_err("This process tree can be restored in a new pid namespace.\n");
pr_err("crtools should be re-executed with --namespace pid\n"); pr_err("crtools should be re-executed with --namespace pid\n");
...@@ -747,7 +747,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts) ...@@ -747,7 +747,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
ret = (int)futex_get(&task_entries->nr_in_progress); ret = (int)futex_get(&task_entries->nr_in_progress);
out: out:
if (init->pid.pid == 1) { if (init->pid.virt == 1) {
int err; int err;
err = umount(proc_mountpoint); err = umount(proc_mountpoint);
if (err == -1) if (err == -1)
...@@ -762,7 +762,7 @@ out: ...@@ -762,7 +762,7 @@ out:
pr_err("Someone can't be restored\n"); pr_err("Someone can't be restored\n");
for_each_pstree_item(pi) for_each_pstree_item(pi)
kill(pi->pid.pid, SIGKILL); kill(pi->pid.virt, SIGKILL);
return 1; return 1;
} }
...@@ -1181,7 +1181,7 @@ static int sigreturn_restore(pid_t pid, struct list_head *tgt_vmas, int nr_vmas) ...@@ -1181,7 +1181,7 @@ static int sigreturn_restore(pid_t pid, struct list_head *tgt_vmas, int nr_vmas)
* Fill up per-thread data. * Fill up per-thread data.
*/ */
for (i = 0; i < me->nr_threads; i++) { for (i = 0; i < me->nr_threads; i++) {
thread_args[i].pid = me->threads[i].pid; thread_args[i].pid = me->threads[i].virt;
/* skip self */ /* skip self */
if (thread_args[i].pid == pid) if (thread_args[i].pid == pid)
......
...@@ -426,7 +426,7 @@ static int show_collect_pstree(int fd_pstree, struct list_head *collect) ...@@ -426,7 +426,7 @@ static int show_collect_pstree(int fd_pstree, struct list_head *collect)
if (!item) if (!item)
return -1; return -1;
item->pid.pid = e.pid; item->pid.virt = e.pid;
item->nr_threads = e.nr_threads; item->nr_threads = e.nr_threads;
item->threads = xzalloc(sizeof(u32) * e.nr_threads); item->threads = xzalloc(sizeof(u32) * e.nr_threads);
if (!item->threads) { if (!item->threads) {
...@@ -446,7 +446,7 @@ static int show_collect_pstree(int fd_pstree, struct list_head *collect) ...@@ -446,7 +446,7 @@ static int show_collect_pstree(int fd_pstree, struct list_head *collect)
goto out; goto out;
pr_msg(" %6d", pid); pr_msg(" %6d", pid);
if (item) if (item)
item->threads[e.nr_threads].pid = pid; item->threads[e.nr_threads].virt = pid;
} }
pr_msg("\n"); pr_msg("\n");
} }
...@@ -649,7 +649,7 @@ static int cr_show_all(struct cr_options *opts) ...@@ -649,7 +649,7 @@ static int cr_show_all(struct cr_options *opts)
show_sk_queues(fd, opts); show_sk_queues(fd, opts);
close(fd); close(fd);
pid = list_first_entry(&pstree_list, struct pstree_item, list)->pid.pid; pid = list_first_entry(&pstree_list, struct pstree_item, list)->pid.virt;
ret = try_show_namespaces(pid, opts); ret = try_show_namespaces(pid, opts);
if (ret) if (ret)
goto out; goto out;
...@@ -657,7 +657,7 @@ static int cr_show_all(struct cr_options *opts) ...@@ -657,7 +657,7 @@ static int cr_show_all(struct cr_options *opts)
list_for_each_entry(item, &pstree_list, list) { list_for_each_entry(item, &pstree_list, list) {
struct cr_fdset *cr_fdset = NULL; struct cr_fdset *cr_fdset = NULL;
cr_fdset = cr_task_fdset_open(item->pid.pid, O_SHOW); cr_fdset = cr_task_fdset_open(item->pid.virt, O_SHOW);
if (!cr_fdset) if (!cr_fdset)
goto out; goto out;
...@@ -668,7 +668,7 @@ static int cr_show_all(struct cr_options *opts) ...@@ -668,7 +668,7 @@ static int cr_show_all(struct cr_options *opts)
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
if (item->threads[i].pid == item->pid.pid) if (item->threads[i].virt == item->pid.virt)
continue; continue;
fd_th = open_image_ro(CR_FD_CORE, item->threads[i]); fd_th = open_image_ro(CR_FD_CORE, item->threads[i]);
...@@ -676,7 +676,7 @@ static int cr_show_all(struct cr_options *opts) ...@@ -676,7 +676,7 @@ static int cr_show_all(struct cr_options *opts)
goto out; goto out;
pr_msg("\n"); pr_msg("\n");
pr_msg("Thread: %d\n", item->threads[i].pid); pr_msg("Thread: %d\n", item->threads[i].virt);
pr_msg("----------------------------------------\n"); pr_msg("----------------------------------------\n");
show_core(fd_th, opts); show_core(fd_th, opts);
......
...@@ -442,7 +442,7 @@ int prepare_fds(struct pstree_item *me) ...@@ -442,7 +442,7 @@ int prepare_fds(struct pstree_item *me)
for (state = 0; state < FD_STATE_MAX; state++) { for (state = 0; state < FD_STATE_MAX; state++) {
list_for_each_entry(fle, &me->rst->fds, ps_list) { list_for_each_entry(fle, &me->rst->fds, ps_list) {
ret = open_fdinfo(me->pid.pid, fle, state); ret = open_fdinfo(me->pid.virt, fle, state);
if (ret) if (ret)
goto done; goto done;
} }
...@@ -453,7 +453,7 @@ int prepare_fds(struct pstree_item *me) ...@@ -453,7 +453,7 @@ int prepare_fds(struct pstree_item *me)
* list and restore at the very end. * list and restore at the very end.
*/ */
list_for_each_entry(fle, &me->rst->eventpoll, ps_list) { list_for_each_entry(fle, &me->rst->eventpoll, ps_list) {
ret = open_fdinfo(me->pid.pid, fle, state); ret = open_fdinfo(me->pid.virt, fle, state);
if (ret) if (ret)
goto done; goto done;
} }
......
...@@ -178,13 +178,13 @@ struct rst_info { ...@@ -178,13 +178,13 @@ struct rst_info {
struct pid struct pid
{ {
u32 real_pid; /* used to peek/poke tasks during dump stage */ u32 real; /* used to peek/poke tasks during dump stage */
u32 pid; /* used all over in the images and saved after restore */ u32 virt; /* used all over in the images and saved after restore */
}; };
struct pstree_item { struct pstree_item {
struct list_head list; struct list_head list;
struct pid pid; /* leader pid */ struct pid pid;
struct pstree_item *parent; struct pstree_item *parent;
struct list_head children; /* array of children */ struct list_head children; /* array of children */
pid_t pgid; pid_t pgid;
......
...@@ -36,25 +36,25 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags) ...@@ -36,25 +36,25 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
struct cr_fdset *fdset; struct cr_fdset *fdset;
int ret = 0; int ret = 0;
fdset = cr_ns_fdset_open(ns_pid->pid, O_DUMP); fdset = cr_ns_fdset_open(ns_pid->virt, O_DUMP);
if (fdset == NULL) if (fdset == NULL)
return -1; return -1;
if (ns_flags & CLONE_NEWUTS) { if (ns_flags & CLONE_NEWUTS) {
pr_info("Dump UTS namespace\n"); pr_info("Dump UTS namespace\n");
ret = dump_uts_ns(ns_pid->real_pid, fdset); ret = dump_uts_ns(ns_pid->real, fdset);
if (ret < 0) if (ret < 0)
goto err; goto err;
} }
if (ns_flags & CLONE_NEWIPC) { if (ns_flags & CLONE_NEWIPC) {
pr_info("Dump IPC namespace\n"); pr_info("Dump IPC namespace\n");
ret = dump_ipc_ns(ns_pid->real_pid, fdset); ret = dump_ipc_ns(ns_pid->real, fdset);
if (ret < 0) if (ret < 0)
goto err; goto err;
} }
if (ns_flags & CLONE_NEWNS) { if (ns_flags & CLONE_NEWNS) {
pr_info("Dump MNT namespace (mountpoints)\n"); pr_info("Dump MNT namespace (mountpoints)\n");
ret = dump_mnt_ns(ns_pid->real_pid, fdset); ret = dump_mnt_ns(ns_pid->real, fdset);
if (ret < 0) if (ret < 0)
goto err; goto err;
} }
...@@ -80,9 +80,9 @@ int dump_namespaces(struct pid *ns_pid, unsigned int ns_flags) ...@@ -80,9 +80,9 @@ int dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
* net namesapce with this is still open * net namesapce with this is still open
*/ */
pr_info("Dumping %d(%d)'s namespaces\n", ns_pid->pid, ns_pid->real_pid); pr_info("Dumping %d(%d)'s namespaces\n", ns_pid->virt, ns_pid->real);
if ((opts.namespaces_flags & CLONE_NEWPID) && ns_pid->pid != 1) { if ((opts.namespaces_flags & CLONE_NEWPID) && ns_pid->virt != 1) {
pr_err("Can't dump a pid namespace without the process init\n"); pr_err("Can't dump a pid namespace without the process init\n");
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment