[16/21] ns: Fixup pid_for_children_ns of threads

Submitted by Kirill Tkhai on May 23, 2017, 12:40 p.m.

Details

Message ID 149554324655.12386.271484163530632851.stgit@localhost.localdomain
State Accepted
Series "Add /proc/[pid]/ns/pid_for_children ns support (and fixes)"
Commit f1aa64a581fd31695af85e1ec2db10708a1654d4
Headers show

Commit Message

Kirill Tkhai May 23, 2017, 12:40 p.m.
Populate pid ns (always) and pid_for_children ns
(if it's empty, i.e., in old dumps).

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/cr-restore.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 944230941..afa66b7d6 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -805,10 +805,23 @@  static int open_cores(int pid, CoreEntry *leader_core)
 	for (i = 0; i < current->nr_threads; i++) {
 		tpid = vtid(current, i);
 
-		if (tpid == pid)
+		if (tpid == pid) {
 			cores[i] = leader_core;
-		else if (open_core(tpid, &cores[i]))
+			continue;
+		}
+
+		if (open_core(tpid, &cores[i]))
 			goto err;
+		if (cores[i]->ids) {
+			/* We don't dump pid_ns_id of threads as it's same to group leader's */
+			cores[i]->ids->has_pid_ns_id = true;
+			cores[i]->ids->pid_ns_id = current->ids->pid_ns_id;
+			if (fixup_pid_for_children_ns(cores[i]->ids)) {
+				core_entry__free_unpacked(cores[i], NULL);
+				goto err;
+			}
+		} else
+			cores[i]->ids = current->ids;
 	}
 
 	current->core = cores;