[CRIU] [PATCH cr 07/13] namespaces: dump_namespaces get a struct pid as argument

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


It uses pid for create image file and real_pid for dumping ns-s.

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

diff --git a/cr-dump.c b/cr-dump.c
index a12bc71..b1f4018 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1735,7 +1735,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 		goto err;
 
 	if (opts->namespaces_flags)
-		if (dump_namespaces(pid, opts->namespaces_flags) < 0)
+		if (dump_namespaces(&root_item->pid, opts->namespaces_flags) < 0)
 			goto err;
 
 	ret = cr_dump_shmem();
diff --git a/include/namespaces.h b/include/namespaces.h
index 80c67af..eed805c 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -1,6 +1,9 @@
 #ifndef __CR_NS_H__
 #define __CR_NS_H__
-int dump_namespaces(int pid, unsigned int ns_flags);
+
+#include "crtools.h"
+
+int dump_namespaces(struct pid *pid, unsigned int ns_flags);
 int prepare_namespace(int pid, unsigned long clone_flags);
 struct cr_options;
 int try_show_namespaces(int pid, struct cr_options *);
diff --git a/namespaces.c b/namespaces.c
index e3121ca..daf6343 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -31,30 +31,30 @@ out:
 	return ret;
 }
 
-static int do_dump_namespaces(int ns_pid, unsigned int ns_flags)
+static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
 {
 	struct cr_fdset *fdset;
 	int ret = 0;
 
-	fdset = cr_ns_fdset_open(ns_pid, O_DUMP);
+	fdset = cr_ns_fdset_open(ns_pid->pid, O_DUMP);
 	if (fdset == NULL)
 		return -1;
 
 	if (ns_flags & CLONE_NEWUTS) {
 		pr_info("Dump UTS namespace\n");
-		ret = dump_uts_ns(ns_pid, fdset);
+		ret = dump_uts_ns(ns_pid->real_pid, fdset);
 		if (ret < 0)
 			goto err;
 	}
 	if (ns_flags & CLONE_NEWIPC) {
 		pr_info("Dump IPC namespace\n");
-		ret = dump_ipc_ns(ns_pid, fdset);
+		ret = dump_ipc_ns(ns_pid->real_pid, fdset);
 		if (ret < 0)
 			goto err;
 	}
 	if (ns_flags & CLONE_NEWNS) {
 		pr_info("Dump MNT namespace (mountpoints)\n");
-		ret = dump_mnt_ns(ns_pid, fdset);
+		ret = dump_mnt_ns(ns_pid->real_pid, fdset);
 		if (ret < 0)
 			goto err;
 	}
@@ -64,7 +64,7 @@ err:
 
 }
 
-int dump_namespaces(int ns_pid, unsigned int ns_flags)
+int dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
 {
 	int pid, status;
 	int ret = 0;
@@ -80,7 +80,7 @@ int dump_namespaces(int ns_pid, unsigned int ns_flags)
 	 * net namesapce with this is still open
 	 */
 
-	pr_info("Dumping %d's namespaces\n", ns_pid);
+	pr_info("Dumping %d(%d)'s namespaces\n", ns_pid->pid, ns_pid->real_pid);
 
 	pid = fork();
 	if (pid < 0) {
-- 
1.7.1



More information about the CRIU mailing list