[CRIU] [PATCH] aio: Restore aio ring content

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 19 07:32:52 PST 2016


We don't restore aio ring buffer memory, but just create a new buffer.
Do that by considering AIO rings as private vmas, and copying its
content to a new allocated AIO buffer during restore.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c   |    6 +++++-
 criu/include/vma.h  |    5 +++--
 criu/pie/restorer.c |    9 ++++++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 67032a3..85f7b21 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -316,6 +316,7 @@ static int map_private_vma(struct vma_area *vma, void **tgt_addr,
 
 	size = vma_entry_len(vma->e);
 	if (paddr == NULL) {
+		int flag = 0;
 		/*
 		 * The respective memory area was NOT found in the parent.
 		 * Map a new one.
@@ -323,9 +324,12 @@ static int map_private_vma(struct vma_area *vma, void **tgt_addr,
 		pr_info("Map 0x%016"PRIx64"-0x%016"PRIx64" 0x%016"PRIx64" vma\n",
 			vma->e->start, vma->e->end, vma->e->pgoff);
 
+		if (vma_entry_is(vma->e, VMA_AREA_AIORING))
+			flag |= MAP_ANONYMOUS;
+
 		addr = mmap(*tgt_addr, size,
 				vma->e->prot | PROT_WRITE,
-				vma->e->flags | MAP_FIXED,
+				vma->e->flags | MAP_FIXED | flag,
 				vma->e->fd, vma->e->pgoff);
 
 		if (addr == MAP_FAILED) {
diff --git a/criu/include/vma.h b/criu/include/vma.h
index 247c5a3..ce4d5f7 100644
--- a/criu/include/vma.h
+++ b/criu/include/vma.h
@@ -95,10 +95,11 @@ static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
 static inline bool vma_entry_is_private(VmaEntry *entry,
 					unsigned long task_size)
 {
-	return vma_entry_is(entry, VMA_AREA_REGULAR)	&&
+	return (vma_entry_is(entry, VMA_AREA_REGULAR)	&&
 		(vma_entry_is(entry, VMA_ANON_PRIVATE)	||
 		 vma_entry_is(entry, VMA_FILE_PRIVATE)) &&
-		 (entry->end <= task_size);
+		 (entry->end <= task_size)) ||
+		vma_entry_is(entry, VMA_AREA_AIORING);
 }
 
 static inline bool vma_area_is_private(struct vma_area *vma,
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 5bcae4f..274309a 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1029,8 +1029,9 @@ long __export_restore_task(struct task_restore_args *args)
 
 	for (i = 0; i < args->rings_n; i++) {
 		struct rst_aio_ring *raio = &args->rings[i];
+		unsigned long *ring = (void *)raio->addr;
 		unsigned long ctx = 0;
-		int ret;
+		int i, count, ret;
 
 		ret = sys_io_setup(raio->nr_req, &ctx);
 		if (ret < 0) {
@@ -1038,8 +1039,10 @@ long __export_restore_task(struct task_restore_args *args)
 			goto core_restore_end;
 		}
 
-		if (ctx == raio->addr) /* Lucky bastards we are! */
-			continue;
+		count = raio->len/sizeof(unsigned long);
+		for (i = 0; i < count; i++)
+			((unsigned long *)ctx)[i] = ring[i];
+		sys_munmap(ring, raio->len);
 
 		/*
 		 * If we failed to get the proper nr_req right and



More information about the CRIU mailing list