Commit 72e462ad authored by Pavel Emelyanov's avatar Pavel Emelyanov

mm: Read mmentry early

We'll merge mm and vma images, so mm should be read in the
same place where vmas are.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ed836740
...@@ -1900,17 +1900,8 @@ static int prepare_creds(int pid, struct task_restore_args *args) ...@@ -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) static int prepare_mm(pid_t pid, struct task_restore_args *args)
{ {
int fd, exe_fd, i, ret = -1; int exe_fd, i, ret = -1;
MmEntry *mm; MmEntry *mm = current->rst->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;
}
args->mm = *mm; args->mm = *mm;
args->mm.n_mm_saved_auxv = 0; args->mm.n_mm_saved_auxv = 0;
...@@ -1926,15 +1917,13 @@ static int prepare_mm(pid_t pid, struct task_restore_args *args) ...@@ -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]; 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) if (exe_fd < 0)
goto out; goto out;
args->fd_exe_link = exe_fd; args->fd_exe_link = exe_fd;
ret = 0; ret = 0;
out: out:
mm_entry__free_unpacked(mm, NULL);
close(fd);
return ret; return ret;
} }
......
...@@ -22,6 +22,8 @@ struct fdt { ...@@ -22,6 +22,8 @@ struct fdt {
futex_t fdt_lock; futex_t fdt_lock;
}; };
struct _MmEntry;
struct rst_info { struct rst_info {
struct list_head fds; struct list_head fds;
struct list_head eventpoll; struct list_head eventpoll;
...@@ -39,6 +41,7 @@ struct rst_info { ...@@ -39,6 +41,7 @@ struct rst_info {
struct fdt *fdt; struct fdt *fdt;
struct vm_area_list vmas; struct vm_area_list vmas;
struct _MmEntry *mm;
union { union {
struct pstree_item *pgrp_leader; struct pstree_item *pgrp_leader;
......
...@@ -347,14 +347,22 @@ int prepare_mm_pid(struct pstree_item *i) ...@@ -347,14 +347,22 @@ int prepare_mm_pid(struct pstree_item *i)
int fd, ret = -1; int fd, ret = -1;
struct rst_info *ri = i->rst; 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 (fd < 0) {
if (errno == ENOENT) if (errno == ENOENT)
return 0; 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) { while (1) {
struct vma_area *vma; struct vma_area *vma;
VmaEntry *vi; VmaEntry *vi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment