[CRIU] [PATCH cr 08/13] dump: split real_pid and pid in struct pid (v2)

Andrey Vagin avagin at openvz.org
Tue Jun 19 07:53:12 EDT 2012


Now pid is dumped from pid ns, it's gotted from parasite.

v2: fail if a zombie is in PIDNS

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-dump.c         |   15 ++++++++++++++-
 include/crtools.h |    2 --
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index b1f4018..4db19cf 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -998,6 +998,7 @@ static int parse_threads(const struct pstree_item *item, struct pid **_t, int *_
 		}
 		t = tmp;
 		t[nr - 1].real_pid = atoi(de->d_name);
+		t[nr - 1].pid = -1;
 		nr++;
 	}
 
@@ -1086,6 +1087,8 @@ struct pstree_item *__alloc_pstree_item(bool rst)
 	INIT_LIST_HEAD(&item->children);
 	item->threads = NULL;
 	item->nr_threads = 0;
+	item->pid.pid = -1;
+	item->pid.real_pid = -1;
 
 	return item;
 }
@@ -1580,8 +1583,18 @@ static int dump_one_task(struct pstree_item *item)
 	if (ret < 0)
 		goto err;
 
-	if (item->state == TASK_DEAD)
+	if (item->state == TASK_DEAD) {
+		/* FIXME don't support zombie in pid name space*/
+		if (root_item->pid.pid == 1) {
+			pr_err("Can't dump a zombie %d in PIDNS", item->pid.real_pid);
+			ret = -1;
+			goto err;
+		}
+		item->pid.pid = item->pid.real_pid;
+
+		BUG_ON(!list_empty(&item->children));
 		return dump_one_zombie(item, &pps_buf);
+	}
 
 	ret = collect_mappings(pid, &vma_area_list);
 	if (ret) {
diff --git a/include/crtools.h b/include/crtools.h
index 6e8ec26..cf3f481 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -177,10 +177,8 @@ struct rst_info {
 
 struct pid
 {
-	union { /* They will be splitted, when crtools will support pid ns */
 	u32 real_pid;
 	u32 pid;
-	};
 };
 
 struct pstree_item {
-- 
1.7.1



More information about the CRIU mailing list