[v1,23/55] pstree: Assign ids for dead tasks in read_pstree_image()

Submitted by Kirill Tkhai on March 24, 2017, 2:59 p.m.

Details

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

Commit Message

Kirill Tkhai March 24, 2017, 2:59 p.m.
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@virtuozzo.com>
---
 criu/pstree.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/pstree.c b/criu/pstree.c
index 762c592b..47711c56 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