[CRIU] [PATCH 4/5] mm: Read mmentry early

Pavel Emelyanov xemul at parallels.com
Mon Feb 3 12:08:44 PST 2014


We'll merge mm and vma images, so mm should be read in the
same place where vmas are.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-restore.c       | 17 +++--------------
 include/rst_info.h |  3 +++
 mem.c              | 14 +++++++++++---
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 89d6136..073ba49 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1900,17 +1900,8 @@ static int prepare_creds(int pid, struct task_restore_args *args)
 
 static int prepare_mm(pid_t pid, struct task_restore_args *args)
 {
-	int fd, exe_fd, i, ret = -1;
-	MmEntry *mm;
-
-	fd = open_image(CR_FD_MM, O_RSTR, pid);
-	if (fd < 0)
-		return -1;
-
-	if (pb_read_one(fd, &mm, PB_MM) < 0) {
-		close_safe(&fd);
-		return -1;
-	}
+	int exe_fd, i, ret = -1;
+	MmEntry *mm = current->rst->mm;
 
 	args->mm = *mm;
 	args->mm.n_mm_saved_auxv = 0;
@@ -1926,15 +1917,13 @@ static int prepare_mm(pid_t pid, struct task_restore_args *args)
 		args->mm_saved_auxv[i] = (auxv_t)mm->mm_saved_auxv[i];
 	}
 
-	exe_fd = open_reg_by_id(args->mm.exe_file_id);
+	exe_fd = open_reg_by_id(mm->exe_file_id);
 	if (exe_fd < 0)
 		goto out;
 
 	args->fd_exe_link = exe_fd;
 	ret = 0;
 out:
-	mm_entry__free_unpacked(mm, NULL);
-	close(fd);
 	return ret;
 }
 
diff --git a/include/rst_info.h b/include/rst_info.h
index 07259ba..6c146cf 100644
--- a/include/rst_info.h
+++ b/include/rst_info.h
@@ -22,6 +22,8 @@ struct fdt {
 	futex_t			fdt_lock;
 };
 
+struct _MmEntry;
+
 struct rst_info {
 	struct list_head	fds;
 	struct list_head	eventpoll;
@@ -39,6 +41,7 @@ struct rst_info {
 	struct fdt		*fdt;
 
 	struct vm_area_list	vmas;
+	struct _MmEntry		*mm;
 
 	union {
 		struct pstree_item	*pgrp_leader;
diff --git a/mem.c b/mem.c
index a4cbfb7..c5c775a 100644
--- a/mem.c
+++ b/mem.c
@@ -347,14 +347,22 @@ int prepare_mm_pid(struct pstree_item *i)
 	int fd, ret = -1;
 	struct rst_info *ri = i->rst;
 
-	fd = open_image(CR_FD_VMAS, O_RSTR, pid);
+	fd = open_image(CR_FD_MM, O_RSTR, pid);
 	if (fd < 0) {
 		if (errno == ENOENT)
 			return 0;
-		else
-			return -1;
+		return -1;
 	}
 
+	ret = pb_read_one(fd, &ri->mm, PB_MM);
+	close(fd);
+	if (ret < 0)
+		return -1;
+
+	fd = open_image(CR_FD_VMAS, O_RSTR, pid);
+	if (fd < 0)
+		return -1;
+
 	while (1) {
 		struct vma_area *vma;
 		VmaEntry *vi;
-- 
1.8.4.2


More information about the CRIU mailing list