[v4,09/41] pstree: Change arguments in parse_pid_status()

Submitted by Kirill Tkhai on May 4, 2017, 4:06 p.m.

Details

Message ID 149391397389.11711.1942868233317029666.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai May 4, 2017, 4:06 p.m.
Pass task or thread there.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/include/proc_parse.h |    3 ++-
 criu/proc_parse.c         |    3 ++-
 criu/seize.c              |   17 ++++++++++++++---
 3 files changed, 18 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/include/proc_parse.h b/criu/include/proc_parse.h
index 2bdc7fd68..98ec88f44 100644
--- a/criu/include/proc_parse.h
+++ b/criu/include/proc_parse.h
@@ -96,7 +96,8 @@  extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s);
 extern unsigned int parse_pid_loginuid(pid_t pid, int *err, bool ignore_noent);
 extern int parse_pid_oom_score_adj(pid_t pid, int *err);
 extern int prepare_loginuid(unsigned int value, unsigned int loglevel);
-extern int parse_pid_status(pid_t pid, struct seize_task_status *, void *data);
+extern int parse_pid_status(pid_t pid, struct seize_task_status *,
+			    struct pstree_item *, struct pid **);
 extern int parse_file_locks(void);
 extern int get_fd_mntid(int fd, int *mnt_id);
 
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 73ea7f648..d4f123904 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -993,7 +993,8 @@  static int cap_parse(char *str, unsigned int *res)
 	return 0;
 }
 
-int parse_pid_status(pid_t pid, struct seize_task_status *ss, void *data)
+int parse_pid_status(pid_t pid, struct seize_task_status *ss,
+		     struct pstree_item *item, struct pid **thread)
 {
 	struct proc_status_creds *cr = container_of(ss, struct proc_status_creds, s);
 	struct bfd f;
diff --git a/criu/seize.c b/criu/seize.c
index cba0a3ecb..5bc127717 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -445,6 +445,11 @@  static inline bool child_collected(struct pstree_item *i, pid_t pid)
 	return false;
 }
 
+static int parse_task_status(int pid, struct seize_task_status *ss, void *item)
+{
+	return parse_pid_status(pid, ss, item, NULL);
+}
+
 static int collect_task(struct pstree_item *item);
 static int collect_children(struct pstree_item *item)
 {
@@ -490,7 +495,7 @@  static int collect_children(struct pstree_item *item)
 			goto free;
 		}
 
-		ret = compel_wait_task(pid, item->pid->real, parse_pid_status, NULL, &creds->s, NULL);
+		ret = compel_wait_task(pid, item->pid->real, parse_task_status, NULL, &creds->s, c);
 		if (ret < 0) {
 			/*
 			 * Here is a race window between parse_children() and seize(),
@@ -675,6 +680,11 @@  static bool creds_dumpable(struct proc_status_creds *parent,
 	return true;
 }
 
+static int parse_thread_status(int pid, struct seize_task_status *ss, void *thread)
+{
+	return parse_pid_status(pid, ss, NULL, thread);
+}
+
 static int collect_threads(struct pstree_item *item)
 {
 	struct pid **threads = NULL;
@@ -720,7 +730,8 @@  static int collect_threads(struct pstree_item *item)
 		if (!opts.freeze_cgroup && compel_interrupt_task(pid))
 			continue;
 
-		ret = compel_wait_task(pid, item_ppid(item), parse_pid_status, NULL, &t_creds.s, NULL);
+		ret = compel_wait_task(pid, item_ppid(item), parse_thread_status, NULL,
+				       &t_creds.s, &item->threads[item->nr_threads]);
 		if (ret < 0) {
 			/*
 			 * Here is a race window between parse_threads() and seize(),
@@ -867,7 +878,7 @@  int collect_pstree(void)
 	if (!creds)
 		goto err;
 
-	ret = compel_wait_task(pid, -1, parse_pid_status, NULL, &creds->s, NULL);
+	ret = compel_wait_task(pid, -1, parse_task_status, NULL, &creds->s, root_item);
 	if (ret < 0)
 		goto err;