[CRIU] [PATCH 2/5] uffd: Relax reading the pstree image (v2)

Pavel Emelyanov xemul at virtuozzo.com
Tue Nov 22 04:10:35 PST 2016


From: Mike Rapoport <rppt at linux.vnet.ibm.com>

The uffd code only needs the pstree items themselves, not
any IDs and relations they might have.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/include/pstree.h |  1 +
 criu/pstree.c         | 17 +++++++++++++++++
 criu/uffd.c           | 17 +----------------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/criu/include/pstree.h b/criu/include/pstree.h
index 5768b64..21a1ae0 100644
--- a/criu/include/pstree.h
+++ b/criu/include/pstree.h
@@ -85,6 +85,7 @@ extern struct pstree_item *pstree_item_next(struct pstree_item *item);
 
 extern bool restore_before_setsid(struct pstree_item *child);
 extern int prepare_pstree(void);
+extern int prepare_dummy_pstree(void);
 
 extern int dump_pstree(struct pstree_item *root_item);
 
diff --git a/criu/pstree.c b/criu/pstree.c
index 943518d..5e17f58 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -16,6 +16,7 @@
 #include "util.h"
 #include "protobuf.h"
 #include "images/pstree.pb-c.h"
+#include "crtools.h"
 
 struct pstree_item *root_item;
 static struct rb_root pid_root_rb;
@@ -943,6 +944,22 @@ int prepare_pstree(void)
 	return ret;
 }
 
+int prepare_dummy_pstree(void)
+{
+	pid_t dummy = 0;
+
+	if (check_img_inventory() == -1)
+		return -1;
+
+	if (prepare_task_entries() == -1)
+		return -1;
+
+	if (read_pstree_image(&dummy) == -1)
+		return -1;
+
+	return 0;
+}
+
 bool restore_before_setsid(struct pstree_item *child)
 {
 	int csid = child->born_sid == -1 ? child->sid : child->born_sid;
diff --git a/criu/uffd.c b/criu/uffd.c
index 94d0863..5697708 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -788,21 +788,6 @@ out:
 
 }
 
-static int lazy_pages_prepare_pstree(void)
-{
-	if (check_img_inventory() == -1)
-		return -1;
-
-	/* Allocate memory for task_entries */
-	if (prepare_task_entries() == -1)
-		return -1;
-
-	if (prepare_pstree() == -1)
-		return -1;
-
-	return 0;
-}
-
 static int prepare_epoll(int nr_fds, struct epoll_event **events)
 {
 	int epollfd;
@@ -923,7 +908,7 @@ int cr_lazy_pages(bool daemon)
 	if (check_for_uffd())
 		return -1;
 
-	if (lazy_pages_prepare_pstree())
+	if (prepare_dummy_pstree())
 		return -1;
 
 	lazy_sk = prepare_lazy_socket();
-- 
2.5.0



More information about the CRIU mailing list