Commit 0ec10e4e authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

dump: save ids on pstree_item

It will be used for determing which resources are shared
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 20b5ed91
...@@ -690,10 +690,12 @@ static DECLARE_KCMP_TREE(fs_tree, KCMP_FS); ...@@ -690,10 +690,12 @@ static DECLARE_KCMP_TREE(fs_tree, KCMP_FS);
static DECLARE_KCMP_TREE(files_tree, KCMP_FILES); static DECLARE_KCMP_TREE(files_tree, KCMP_FILES);
static DECLARE_KCMP_TREE(sighand_tree, KCMP_SIGHAND); static DECLARE_KCMP_TREE(sighand_tree, KCMP_SIGHAND);
static int dump_task_kobj_ids(pid_t pid, TaskKobjIdsEntry *ids) static int dump_task_kobj_ids(struct pstree_item *item)
{ {
int new; int new;
struct kid_elem elem; struct kid_elem elem;
int pid = item->pid.real;
TaskKobjIdsEntry *ids = item->ids;
elem.pid = pid; elem.pid = pid;
elem.idx = 0; /* really 0 for all */ elem.idx = 0; /* really 0 for all */
...@@ -763,29 +765,30 @@ err: ...@@ -763,29 +765,30 @@ err:
return NULL; return NULL;
} }
static int dump_task_ids(pid_t pid, const struct cr_fdset *cr_fdset) static int dump_task_ids(struct pstree_item *item, const struct cr_fdset *cr_fdset)
{ {
int fd_ids = fdset_fd(cr_fdset, CR_FD_IDS); int fd_ids = fdset_fd(cr_fdset, CR_FD_IDS);
TaskKobjIdsEntry *ids;
int ret; int ret;
ids = xmalloc(sizeof(*ids)); item->ids = xmalloc(sizeof(*item->ids));
if (!ids) if (!item->ids)
return -1; return -1;
task_kobj_ids_entry__init(ids); task_kobj_ids_entry__init(item->ids);
ret = dump_task_kobj_ids(pid, ids); ret = dump_task_kobj_ids(item);
if (ret) if (ret)
goto err_free; goto err_free;
ret = pb_write_one(fd_ids, ids, PB_IDS); ret = pb_write_one(fd_ids, item->ids, PB_IDS);
if (ret < 0) if (ret < 0)
goto err_free; goto err_free;
err_free:
xfree(ids);
return ret; return ret;
err_free:
xfree(item->ids);
item->ids = NULL;
return -1;
} }
static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat, static int dump_task_core_all(pid_t pid, const struct proc_pid_stat *stat,
...@@ -1481,7 +1484,7 @@ static int dump_one_task(struct pstree_item *item) ...@@ -1481,7 +1484,7 @@ static int dump_one_task(struct pstree_item *item)
goto err_cure; goto err_cure;
} }
ret = dump_task_ids(pid, cr_fdset); ret = dump_task_ids(item, cr_fdset);
if (ret) { if (ret) {
pr_err("Dump ids (pid: %d) failed with %d\n", pid, ret); pr_err("Dump ids (pid: %d) failed with %d\n", pid, ret);
goto err_cure; goto err_cure;
......
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