[CRIU] [PATCH 09/11] vma: Do not open vmas when inheriting
Pavel Emelyanov
xemul at virtuozzo.com
Thu May 11 02:13:14 PDT 2017
Inherited VMAs don't need the descriptor to work with.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/mem.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/criu/mem.c b/criu/mem.c
index a5ab75b..ee48060 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -648,16 +648,6 @@ static int premap_private_vma(struct pstree_item *t, struct vma_area *vma, void
void *addr;
unsigned long nr_pages, size;
- if (vma_area_is(vma, VMA_FILE_PRIVATE)) {
- ret = vma->vm_open(vpid(t), vma);
- if (ret < 0) {
- pr_err("Can't fixup VMA's fd\n");
- return -1;
- }
-
- vma->vm_open = NULL; /* prevent from 2nd open in prepare_vmas */
- }
-
nr_pages = vma_entry_len(vma->e) / PAGE_SIZE;
vma->page_bitmap = xzalloc(BITS_TO_LONGS(nr_pages) * sizeof(long));
if (vma->page_bitmap == NULL)
@@ -684,6 +674,13 @@ static int premap_private_vma(struct pstree_item *t, struct vma_area *vma, void
*/
if (vma_entry_is(vma->e, VMA_AREA_AIORING))
flag |= MAP_ANONYMOUS;
+ else if (vma_area_is(vma, VMA_FILE_PRIVATE)) {
+ ret = vma->vm_open(vpid(t), vma);
+ if (ret < 0) {
+ pr_err("Can't fixup VMA's fd\n");
+ return -1;
+ }
+ }
addr = mmap(*tgt_addr, size,
vma->e->prot | PROT_WRITE,
@@ -694,6 +691,9 @@ static int premap_private_vma(struct pstree_item *t, struct vma_area *vma, void
pr_perror("Unable to map ANON_VMA");
return -1;
}
+
+ if (vma_area_is(vma, VMA_FILE_PRIVATE))
+ close(vma->e->fd);
} else {
void *paddr;
@@ -727,7 +727,7 @@ static int premap_private_vma(struct pstree_item *t, struct vma_area *vma, void
}
if (vma_area_is(vma, VMA_FILE_PRIVATE))
- close(vma->e->fd);
+ vma->vm_open = NULL; /* prevent from 2nd open in prepare_vmas */
*tgt_addr += size;
return 0;
--
2.1.4
More information about the CRIU
mailing list