[CRIU] [PATCH cr 07/11] restorer: remap private vmas to correct
places
Andrey Vagin
avagin at openvz.org
Mon Oct 15 11:32:20 EDT 2012
All private vmas were restored before forking children, but
in this moment they could not be remapped to correct places,
because crtools' mappings may conflict with them.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 2 +-
restorer.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 6f465e9..860109c 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1380,7 +1380,7 @@ static int mark_target_vmas(struct list_head *self_vma_list)
list_for_each_entry(n, &vma_list, list) {
unsigned long start = vma->vma.start;
- if (!vma_anon(&n->vma))
+ if (!vma_priv(&n->vma))
continue;
if (n->vma.flags & MAP_GROWSDOWN)
diff --git a/restorer.c b/restorer.c
index 04337a9..75c09a0 100644
--- a/restorer.c
+++ b/restorer.c
@@ -337,6 +337,30 @@ long __export_restore_task(struct task_restore_core_args *args)
if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
continue;
+ if (!vma_priv(vma_entry))
+ continue;
+
+ va = sys_mremap(vma_entry->shmid,
+ vma_entry_len(vma_entry), vma_entry_len(vma_entry),
+ MREMAP_MAYMOVE | MREMAP_FIXED, vma_entry->start);
+ if (va != vma_entry->start) {
+ pr_err("Unable to remap %lx -> %lx mapping with %lx\n",
+ vma_entry->shmid, vma_entry->start, va);
+ while(1);
+ goto core_restore_end;
+ }
+ }
+
+ /*
+ * OK, lets try to map new one.
+ */
+ for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
+ if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
+ continue;
+
+ if (vma_priv(vma_entry))
+ continue;
+
va = restore_mapping(vma_entry);
if (va != vma_entry->start) {
--
1.7.1
More information about the CRIU
mailing list