Commit 32650788 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

restore: Make target vmas list global

Makes further patching simpler
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 11ed3531
...@@ -62,9 +62,12 @@ ...@@ -62,9 +62,12 @@
static struct pstree_item *current; static struct pstree_item *current;
static int restore_task_with_children(void *); static int restore_task_with_children(void *);
static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *vmas, int nr_vmas); static int sigreturn_restore(pid_t pid, CoreEntry *core);
static int prepare_restorer_blob(void); static int prepare_restorer_blob(void);
static LIST_HEAD(rst_vma_list);
static int rst_nr_vmas;
static int shmem_remap(void *old_addr, void *new_addr, unsigned long size) static int shmem_remap(void *old_addr, void *new_addr, unsigned long size)
{ {
void *ret; void *ret;
...@@ -176,14 +179,14 @@ err: ...@@ -176,14 +179,14 @@ err:
return ret; return ret;
} }
static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas) static int read_vmas(int pid)
{ {
int fd, ret = 0; int fd, ret = 0;
LIST_HEAD(old); LIST_HEAD(old);
struct vma_area *vma; struct vma_area *vma;
*nr_vmas = 0; rst_nr_vmas = 0;
list_replace_init(vmas, &old); list_replace_init(&rst_vma_list, &old);
/* Skip errors, because a zombie doesn't have an image of vmas */ /* Skip errors, because a zombie doesn't have an image of vmas */
fd = open_image_ro(CR_FD_VMAS, pid); fd = open_image_ro(CR_FD_VMAS, pid);
...@@ -206,8 +209,8 @@ static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas) ...@@ -206,8 +209,8 @@ static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas)
if (ret <= 0) if (ret <= 0)
break; break;
(*nr_vmas)++; rst_nr_vmas++;
list_add_tail(&vma->list, vmas); list_add_tail(&vma->list, &rst_vma_list);
if (e->fd != -1) { if (e->fd != -1) {
ret = -1; ret = -1;
...@@ -282,7 +285,7 @@ static int prepare_and_sigreturn(int pid, CoreEntry *core) ...@@ -282,7 +285,7 @@ static int prepare_and_sigreturn(int pid, CoreEntry *core)
if (err) if (err)
return err; return err;
return sigreturn_restore(pid, core, &vma_list, nr_vmas); return sigreturn_restore(pid, core);
} }
static rt_sigaction_t sigchld_act; static rt_sigaction_t sigchld_act;
...@@ -1348,7 +1351,7 @@ static int prep_sched_info(struct rst_sched_param *sp, ThreadCoreEntry *tc) ...@@ -1348,7 +1351,7 @@ static int prep_sched_info(struct rst_sched_param *sp, ThreadCoreEntry *tc)
return 0; return 0;
} }
static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_vmas, int nr_vmas) static int sigreturn_restore(pid_t pid, CoreEntry *core)
{ {
long restore_task_vma_len; long restore_task_vma_len;
long restore_thread_vma_len, self_vmas_len, vmas_len; long restore_thread_vma_len, self_vmas_len, vmas_len;
...@@ -1382,7 +1385,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v ...@@ -1382,7 +1385,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
mark_stack_vma((long) &self_vma_list, &self_vma_list); mark_stack_vma((long) &self_vma_list, &self_vma_list);
self_vmas_len = round_up((ret + 1) * sizeof(VmaEntry), PAGE_SIZE); self_vmas_len = round_up((ret + 1) * sizeof(VmaEntry), PAGE_SIZE);
vmas_len = round_up((nr_vmas + 1) * sizeof(VmaEntry), PAGE_SIZE); vmas_len = round_up((rst_nr_vmas + 1) * sizeof(VmaEntry), PAGE_SIZE);
/* pr_info_vma_list(&self_vma_list); */ /* pr_info_vma_list(&self_vma_list); */
...@@ -1410,7 +1413,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v ...@@ -1410,7 +1413,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
SHMEMS_SIZE + TASK_ENTRIES_SIZE + SHMEMS_SIZE + TASK_ENTRIES_SIZE +
self_vmas_len + vmas_len + self_vmas_len + vmas_len +
rst_tcp_socks_size; rst_tcp_socks_size;
exec_mem_hint = restorer_get_vma_hint(pid, tgt_vmas, &self_vma_list, exec_mem_hint = restorer_get_vma_hint(pid, &rst_vma_list, &self_vma_list,
restore_bootstrap_len); restore_bootstrap_len);
if (exec_mem_hint == -1) { if (exec_mem_hint == -1) {
pr_err("No suitable area for task_restore bootstrap (%ldK)\n", pr_err("No suitable area for task_restore bootstrap (%ldK)\n",
...@@ -1483,7 +1486,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v ...@@ -1483,7 +1486,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *tgt_v
goto err; goto err;
mem += self_vmas_len; mem += self_vmas_len;
task_args->tgt_vmas = vma_list_remap(mem, vmas_len, tgt_vmas); task_args->tgt_vmas = vma_list_remap(mem, vmas_len, &rst_vma_list);
if (!task_args->tgt_vmas) if (!task_args->tgt_vmas)
goto err; goto err;
......
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