[CRIU] [PATCH cr 08/11] restore: use a new scheme for restoring of
file private mappings
Andrey Vagin
avagin at openvz.org
Mon Oct 15 11:32:21 EDT 2012
With this patch vma->shmid contains file id before mapping a region,
then it contains of a temporary address.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 17 ++++++++++++++---
include/restorer.h | 5 +++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 860109c..b159124 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -177,11 +177,23 @@ err:
static int map_private_vma(pid_t pid, struct vma_area *vma,
struct vma_area **pvma, struct list_head *pvma_list)
{
+ int ret;
struct vma_area *p = *pvma;
if (!vma_priv(&vma->vma))
return 0;
+ if (vma_entry_is(&vma->vma, VMA_FILE_PRIVATE)) {
+ ret = get_filemap_fd(pid, &vma->vma);
+ if (ret < 0) {
+ pr_err("Can't fixup fd\n");
+ return -1;
+ }
+ vma->vma.fd = ret;
+ /* shmid will be used for a temporary address */
+ vma->vma.shmid = 0;
+ }
+
list_for_each_entry_continue(p, pvma_list, list) {
if (p->vma.start > vma->vma.start)
break;
@@ -281,7 +293,7 @@ out:
static int open_vmas(int pid, struct list_head *vmas)
{
struct vma_area *vma;
- int fd, ret = -1;
+ int fd, ret = 0;
fd = open_image_ro(CR_FD_VMAS, pid);
if (fd < 0)
@@ -298,8 +310,7 @@ static int open_vmas(int pid, struct list_head *vmas)
ret = vma->vma.shmid;
else if (vma_entry_is(&vma->vma, VMA_ANON_SHARED))
ret = get_shmem_fd(pid, &vma->vma);
- else if (vma_entry_is(&vma->vma, VMA_FILE_PRIVATE) ||
- vma_entry_is(&vma->vma, VMA_FILE_SHARED))
+ else if (vma_entry_is(&vma->vma, VMA_FILE_SHARED))
ret = get_filemap_fd(pid, &vma->vma);
else
continue;
diff --git a/include/restorer.h b/include/restorer.h
index 93e4160..9cc4b3f 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -265,7 +265,8 @@ find_shmem(struct shmems *shmems, unsigned long shmid)
return NULL;
}
-#define vma_priv(vma) (vma_entry_is(vma, VMA_AREA_REGULAR) && \
- vma_entry_is(vma, VMA_ANON_PRIVATE))
+#define vma_priv(vma) ((vma_entry_is(vma, VMA_AREA_REGULAR)) && \
+ (vma_entry_is(vma, VMA_ANON_PRIVATE) || \
+ vma_entry_is(vma, VMA_FILE_PRIVATE)))
#endif /* CR_RESTORER_H__ */
--
1.7.1
More information about the CRIU
mailing list