Commit 3302183c authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

restore: Pass self-vma file descriptor directly

Instead of passing self-vma file path to restorer
code simply open it before restore_task call and
pass descriptor instead. This saves some memory.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent acfd1d7f
......@@ -1341,8 +1341,16 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
if (get_image_path(self_vmas_path, sizeof(self_vmas_path), FMT_FNAME_VMAS, getpid()))
goto err;
fd_self_vmas = open(self_vmas_path, O_CREAT | O_RDWR | O_TRUNC, CR_FD_PERM);
/*
* This is a temporary file used to pass vma info to
* restorer code, thus unlink it early to make it disappear
* as soon as we close it
*/
unlink(self_vmas_path);
fd_self_vmas = open(self_vmas_path, O_CREAT | O_RDWR, CR_FD_PERM);
if (fd_self_vmas < 0) {
pr_perror("Can't open %s\n", self_vmas_path);
goto err;
......@@ -1482,9 +1490,6 @@ static void sigreturn_restore(pid_t pstree_pid, pid_t pid)
task_args->fd_core = fd_core;
task_args->fd_self_vmas = fd_self_vmas;
task_args->shmems_fd = ret;
strncpy(task_args->self_vmas_path,
self_vmas_path,
sizeof(task_args->self_vmas_path));
cr_mutex_init(&task_args->rst_lock);
......
......@@ -66,7 +66,6 @@ struct task_restore_core_args {
int fd_core; /* opened core file */
int fd_self_vmas; /* opened file with running VMAs to unmap */
union {
char self_vmas_path[PATH_MAX];/* path to it, to unlink it once we're done */
char last_pid_buf[PATH_MAX]; /* internal buffer to save stack space */
};
char ns_last_pid_path[PATH_MAX];
......
......@@ -211,7 +211,6 @@ self_len_end:
}
sys_close(args->fd_self_vmas);
sys_unlink(args->self_vmas_path);
/*
* OK, lets try to map new one.
......
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