[CRIU] [crtools-bot for Pavel Emelyanov ] restore: Cleanup mem
variables usage
Cyrill Gorcunov
gorcunov at openvz.org
Fri Mar 2 12:31:35 EST 2012
The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 471d3c429c80ca9b51b50923e622803a28761b1c
Author: Pavel Emelyanov <xemul at parallels.com>
Date: Fri Mar 2 19:29:35 2012 +0400
restore: Cleanup mem variables usage
Just prepare the code for smoother further bootstrap areas allocation.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
cr-restore.c | 30 +++++++++++-------------------
1 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 7ae5152..4ef8c5e 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1630,11 +1630,10 @@ static void sigreturn_restore(pid_t pid)
long restore_code_len, restore_task_vma_len;
long restore_thread_vma_len;
- void *exec_mem = MAP_FAILED;
+ void *mem = MAP_FAILED;
void *restore_thread_exec_start;
void *restore_task_exec_start;
void *restore_code_start;
- void *shmems_ref;
long new_sp, exec_mem_hint;
long ret;
@@ -1752,11 +1751,11 @@ static void sigreturn_restore(pid_t pid)
free_mappings(&self_vma_list);
/* VMA we need to run task_restore code */
- exec_mem = mmap((void *)exec_mem_hint,
+ mem = mmap((void *)exec_mem_hint,
restore_task_vma_len + restore_thread_vma_len,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
- if (exec_mem != (void *)exec_mem_hint) {
+ if (mem != (void *)exec_mem_hint) {
pr_err("Can't mmap section for restore code\n");
goto err;
}
@@ -1765,7 +1764,7 @@ static void sigreturn_restore(pid_t pid)
* Prepare a memory map for restorer. Note a thread space
* might be completely unused so it's here just for convenience.
*/
- restore_code_start = exec_mem;
+ restore_code_start = mem;
restore_thread_exec_start = restore_code_start + restorer_blob_offset__restore_thread;
restore_task_exec_start = restore_code_start + restorer_blob_offset__restore_task;
task_args = restore_code_start + restore_code_len;
@@ -1794,22 +1793,18 @@ static void sigreturn_restore(pid_t pid)
* but this area is taken into account for 'hint' memory
* address.
*/
- shmems_ref = (struct shmems *)(exec_mem +
- restore_task_vma_len +
- restore_thread_vma_len);
- ret = shmem_remap(shmems, shmems_ref, SHMEMS_SIZE);
+
+ mem += restore_task_vma_len + restore_thread_vma_len;
+ ret = shmem_remap(shmems, mem, SHMEMS_SIZE);
if (ret < 0)
goto err;
- task_args->shmems = shmems_ref;
+ task_args->shmems = mem;
- shmems_ref = (struct shmems *)(exec_mem +
- restore_task_vma_len +
- restore_thread_vma_len +
- SHMEMS_SIZE);
- ret = shmem_remap(task_entries, shmems_ref, TASK_ENTRIES_SIZE);
+ mem += SHMEMS_SIZE;
+ ret = shmem_remap(task_entries, mem, TASK_ENTRIES_SIZE);
if (ret < 0)
goto err;
- task_args->task_entries = shmems_ref;
+ task_args->task_entries = mem;
/*
* Arguments for task restoration.
@@ -1896,9 +1891,6 @@ err:
close_safe(&fd_fdinfo);
close_safe(&fd_self_vmas);
- if (exec_mem != MAP_FAILED)
- munmap(exec_mem, restore_task_vma_len + restore_thread_vma_len);
-
/* Just to be sure */
exit(1);
}
More information about the CRIU
mailing list