[CRIU] [PATCH 04/11] lazy-pages: initialize process tree early

Mike Rapoport rppt at linux.vnet.ibm.com
Sun Apr 10 23:19:47 PDT 2016


Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/uffd.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 9642fad..254a5b3 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -5,6 +5,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <string.h>
 #include <time.h>
 #include <sys/stat.h>
@@ -428,19 +429,8 @@ static int find_vmas(struct list_head *uffd_list)
 	struct page_read pr;
 	struct uffd_pages_struct *uffd_pages;
 
-
-	if (check_img_inventory() == -1)
-		return -1;
-
 	vm_area_list_init(&vmas);
 
-	/* Allocate memory for task_entries */
-	if (prepare_task_entries() == -1)
-		return -1;
-
-	if (prepare_pstree() == -1)
-		return -1;
-
 	ri = rsti(root_item);
 	if (!ri)
 		return -1;
@@ -629,6 +619,27 @@ 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;
+
+	/* bail out early until we know how to handle multiple tasks */
+	if (task_entries->nr_tasks > 1) {
+		pr_msg("lazy-pages cannot restore more than one task, sorry\n");
+		return -1;
+	}
+
+	return 0;
+}
+
 int cr_lazy_pages()
 {
 	int listen;
@@ -645,6 +656,9 @@ int cr_lazy_pages()
 		return -1;
 	}
 
+	if (lazy_pages_prepare_pstree())
+		return -1;
+
 	pr_debug("Waiting for incoming connections on %s\n", opts.addr);
 	if ((listen = server_listen(&saddr)) < 0) {
 		pr_perror("server_listen error");
-- 
1.9.1



More information about the CRIU mailing list