mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
restore: split read_and_open_vmas into parts read_vmas and open_vmas (v2)
read_vmas will be called bedore forking children to restore copy-on-write memory. v2: don't open an image one more time Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
0c77eaba1b
commit
ec583c7408
22
cr-restore.c
22
cr-restore.c
@@ -176,7 +176,7 @@ err:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_and_open_vmas(int pid, struct list_head *vmas, int *nr_vmas)
|
static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas)
|
||||||
{
|
{
|
||||||
int fd, ret = -1;
|
int fd, ret = -1;
|
||||||
|
|
||||||
@@ -209,7 +209,18 @@ static int read_and_open_vmas(int pid, struct list_head *vmas, int *nr_vmas)
|
|||||||
|
|
||||||
vma->vma = *e;
|
vma->vma = *e;
|
||||||
vma_entry__free_unpacked(e, NULL);
|
vma_entry__free_unpacked(e, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int open_vmas(int pid, struct list_head *vmas)
|
||||||
|
{
|
||||||
|
struct vma_area *vma;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
list_for_each_entry(vma, vmas, list) {
|
||||||
if (!(vma_entry_is(&vma->vma, VMA_AREA_REGULAR)))
|
if (!(vma_entry_is(&vma->vma, VMA_AREA_REGULAR)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -238,8 +249,7 @@ static int read_and_open_vmas(int pid, struct list_head *vmas, int *nr_vmas)
|
|||||||
vma->vma.fd = ret;
|
vma->vma.fd = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
return ret < 0 ? -1 : 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepare_and_sigreturn(int pid, CoreEntry *core)
|
static int prepare_and_sigreturn(int pid, CoreEntry *core)
|
||||||
@@ -247,7 +257,11 @@ static int prepare_and_sigreturn(int pid, CoreEntry *core)
|
|||||||
int err, nr_vmas;
|
int err, nr_vmas;
|
||||||
LIST_HEAD(vma_list);
|
LIST_HEAD(vma_list);
|
||||||
|
|
||||||
err = read_and_open_vmas(pid, &vma_list, &nr_vmas);
|
err = read_vmas(pid, &vma_list, &nr_vmas);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = open_vmas(pid, &vma_list);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user