[CRIU] [PATCH 08/10] pstree: Store task's netns on pstree-item

Pavel Emelyanov xemul at parallels.com
Mon Sep 29 11:05:17 PDT 2014


Will be needed for parasite sockets.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 image.c          | 15 +++++++++------
 include/pstree.h |  2 ++
 namespaces.c     |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/image.c b/image.c
index 99cabb3..f0cf3e4 100644
--- a/image.c
+++ b/image.c
@@ -67,7 +67,10 @@ int write_img_inventory(void)
 {
 	struct cr_img *img;
 	InventoryEntry he = INVENTORY_ENTRY__INIT;
-	struct pstree_item crt = { };
+	struct {
+		struct pstree_item i;
+		struct dmp_info d;
+	} crt = { };
 
 	pr_info("Writing image inventory (version %u)\n", CRTOOLS_IMAGES_V1);
 
@@ -81,9 +84,9 @@ int write_img_inventory(void)
 	he.ns_per_id = true;
 	he.has_ns_per_id = true;
 
-	crt.state = TASK_ALIVE;
-	crt.pid.real = getpid();
-	if (get_task_ids(&crt)) {
+	crt.i.state = TASK_ALIVE;
+	crt.i.pid.real = getpid();
+	if (get_task_ids(&crt.i)) {
 		close_image(img);
 		return -1;
 	}
@@ -92,12 +95,12 @@ int write_img_inventory(void)
 	if (dump_task_cgroup(NULL, &he.root_cg_set))
 		return -1;
 
-	he.root_ids = crt.ids;
+	he.root_ids = crt.i.ids;
 
 	if (pb_write_one(img, &he, PB_INVENTORY) < 0)
 		return -1;
 
-	xfree(crt.ids);
+	xfree(crt.i.ids);
 	close_image(img);
 	return 0;
 }
diff --git a/include/pstree.h b/include/pstree.h
index d21a884..bd9c2e8 100644
--- a/include/pstree.h
+++ b/include/pstree.h
@@ -36,7 +36,9 @@ static inline struct rst_info *rsti(struct pstree_item *i)
 	return (struct rst_info *)(i + 1);
 }
 
+struct ns_id;
 struct dmp_info {
+	struct ns_id *netns;
 };
 
 static inline struct dmp_info *dmpi(struct pstree_item *i)
diff --git a/namespaces.c b/namespaces.c
index cc55bc6..b1ab0df 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -372,7 +372,7 @@ int dump_task_ns_ids(struct pstree_item *item)
 	}
 
 	ids->has_net_ns_id = true;
-	ids->net_ns_id = get_ns_id(pid, &net_ns_desc);
+	ids->net_ns_id = __get_ns_id(pid, &net_ns_desc, &dmpi(item)->netns);
 	if (!ids->net_ns_id) {
 		pr_err("Can't make netns id\n");
 		return -1;
-- 
1.8.4.2




More information about the CRIU mailing list