mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 01:59:04 +00:00
restore: Dump current VMAs
Restorer needs to know which VMAs to unmap before map a new set. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
2cc7488de2
commit
aaf3291e00
3 changed files with 38 additions and 4 deletions
32
cr-restore.c
32
cr-restore.c
|
|
@ -1229,6 +1229,33 @@ static void restorer_test(pid_t pid)
|
|||
restorer_fcall_t restorer_fcall;
|
||||
char path[64];
|
||||
|
||||
LIST_HEAD(self_vma_list);
|
||||
struct vma_area *vma_area;
|
||||
int fd_vmas, num;
|
||||
|
||||
if (parse_maps(getpid(), &self_vma_list, false))
|
||||
goto err;
|
||||
|
||||
snprintf(path, sizeof(path), "vmas-%d.img", getpid());
|
||||
unlink(path);
|
||||
fd_vmas = open(path, O_CREAT | O_WRONLY, CR_FD_PERM);
|
||||
if (fd_vmas < 0) {
|
||||
pr_perror("Can't open %s\n", path);
|
||||
}
|
||||
|
||||
num = 0;
|
||||
list_for_each_entry(vma_area, &self_vma_list, list) {
|
||||
ret = write(fd_vmas, &vma_area->vma, sizeof(vma_area->vma));
|
||||
if (ret != sizeof(vma_area->vma)) {
|
||||
pr_perror("\nUnable to write vma entry (%li written)\n", num);
|
||||
goto err;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
free_mappings(&self_vma_list);
|
||||
close(fd_vmas);
|
||||
|
||||
restorer_fcall = restorer;
|
||||
code_len = restorer_fcall(RESTORER_CMD__GET_SELF_LEN) - (long)restorer;
|
||||
args_offset = restorer_fcall(RESTORER_CMD__GET_ARG_OFFSET) - (long)restorer;
|
||||
|
|
@ -1265,10 +1292,12 @@ static void restorer_test(pid_t pid)
|
|||
/*
|
||||
* Pass arguments and run a command.
|
||||
*/
|
||||
snprintf(path, sizeof(path), "core-%d.img", pid);
|
||||
args = (struct restore_core_args *)(exec_start + args_offset);
|
||||
args->self_entry = exec_mem;
|
||||
args->self_size = vma_len;
|
||||
|
||||
strcpy(args->self_vmas_path, path);
|
||||
snprintf(path, sizeof(path), "core-%d.img", pid);
|
||||
strcpy(args->core_path, path);
|
||||
|
||||
/*
|
||||
|
|
@ -1285,6 +1314,7 @@ static void restorer_test(pid_t pid)
|
|||
: "g"(new_sp), "g"(exec_start)
|
||||
: "rsp", "rdi", "rbx", "rax", "memory");
|
||||
|
||||
err:
|
||||
/* Just to be sure */
|
||||
sys_exit(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ typedef long (*restorer_fcall_t) (long cmd);
|
|||
#define RESTORER_CMD__RESTORE_CORE 4
|
||||
|
||||
struct restore_core_args {
|
||||
void *self_entry; /* restorer placed at */
|
||||
long self_size; /* size for restorer granted */
|
||||
char core_path[0]; /* path to a core file */
|
||||
void *self_entry; /* restorer placed at */
|
||||
long self_size; /* size for restorer granted */
|
||||
char core_path[64]; /* path to a core file */
|
||||
char self_vmas_path[64]; /* path to a self-vmas file */
|
||||
};
|
||||
|
||||
struct rt_sigframe {
|
||||
|
|
|
|||
|
|
@ -95,6 +95,9 @@ self_len_end:
|
|||
write_string(args->core_path);
|
||||
write_string("\n");
|
||||
|
||||
write_string(args->self_vmas_path);
|
||||
write_string("\n");
|
||||
|
||||
fd_core = sys_open(args->core_path, O_RDONLY, CR_FD_PERM);
|
||||
if (fd_core < 0)
|
||||
return fd_core;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue