[CRIU] [PATCH v3 20/55] pstree: Assign ids for dead tasks in read_pstree_image()

Kirill Tkhai ktkhai at virtuozzo.com
Mon Apr 10 01:18:21 PDT 2017


Alive tasks must have ids populated, while dead tasks have
pid and user namespaces are set (in Linux). But we never
dumped ids for dead tasks.

Since we have no support nested pid ns yet, only one pid_ns
is possible in existing dumps, so it must be equal to
root_item's. User ns is not so, but currently it's impossible
to know dead task's user ns from the dump, so set it
to root_item's too.

In further, we're going to dump ids for all tasks: see next
patches for that. This patch is only to handle old images
with unexisting dead tasks's ids.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/pstree.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/criu/pstree.c b/criu/pstree.c
index 762c592b3..47711c567 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -565,6 +565,15 @@ static int read_pstree_image(pid_t *pid_max)
 			parent = pid->item;
 		}
 
+		if (!ids) {
+			/* In not corrupted old image, only dead tasks don't have ids */
+			if (!parent || !parent->ids) {
+				pr_err("No root_item or its ids\n");
+				break;
+			}
+			ids = parent->ids;
+		}
+
 		pi = lookup_create_item(e->pid);
 		if (pi == NULL)
 			break;
@@ -865,16 +874,6 @@ static int prepare_pstree_kobj_ids(void)
 		TaskKobjIdsEntry *ids;
 		unsigned long cflags;
 
-		if (!item->ids) {
-			if (item == root_item) {
-				pr_err("No IDS for root task.\n");
-				pr_err("Images currupted or too old criu was used for dump.\n");
-				return -1;
-			}
-
-			continue;
-		}
-
 		if (parent)
 			ids = parent->ids;
 		else



More information about the CRIU mailing list