2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00
Files
criu/include/vma.h
Saied Kazemi d8b41b6525 Added AUFS support.
The AUFS support code handles the "bad" information that we get from
the kernel in /proc/<pid>/map_files and /proc/<pid>/mountinfo files.
For details see comments in sysfs_parse.c.

The main motivation for this work was dumping and restoring Docker
containers which by default use the AUFS graph driver.  For dump,
--aufs-root <container_root> should be added to the command line options.
For restore, there is no need for AUFS-specific command line options
but the container's AUFS filesystem should already be set up before
calling criu restore.

[ xemul: With AUFS files sometimes, in particular -- in case of a
  mapping of an executable file (likekely the one created at elf load),
  in the /proc/pid/map_files/xxx link target we see not the path
  by which the file is seen in AUFS, but the path by which AUFS
  accesses this file from one of its "branches". In order to fix
  the path we get the info about branches from sysfs and when we
  meet such a file, we cut the branch part of the path. ]

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-21 18:35:22 +04:00

76 lines
1.9 KiB
C

#ifndef __CR_VMA_H__
#define __CR_VMA_H__
#include "list.h"
#include "protobuf/vma.pb-c.h"
struct vm_area_list {
struct list_head h;
unsigned nr;
unsigned long priv_size; /* nr of pages in private VMAs */
unsigned long longest; /* nr of pages in longest VMA */
};
#define VM_AREA_LIST(name) struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, }
static inline void vm_area_list_init(struct vm_area_list *vml)
{
INIT_LIST_HEAD(&vml->h);
vml->nr = 0;
vml->priv_size = 0;
vml->longest = 0;
}
struct file_desc;
struct vma_area {
struct list_head list;
VmaEntry *e;
union {
int vm_file_fd;
int vm_socket_id;
struct file_desc *fd;
};
union {
unsigned long *page_bitmap; /* existent pages, restore only */
char *aufs_rpath; /* path from aufs root, dump only */
};
union {
unsigned long *ppage_bitmap; /* parent's existent pages */
char *aufs_fpath; /* full path from global root, dump only */
};
unsigned long premmaped_addr;
bool file_borrowed;
struct stat *st;
};
extern struct vma_area *alloc_vma_area(void);
extern int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list);
extern void free_mappings(struct vm_area_list *vma_area_list);
extern bool privately_dump_vma(struct vma_area *vma);
#define vma_area_is(vma_area, s) vma_entry_is((vma_area)->e, s)
#define vma_area_len(vma_area) vma_entry_len((vma_area)->e)
#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s))
#define vma_entry_len(vma) ((vma)->end - (vma)->start)
/*
* vma_premmaped_start() can be used only in restorer.
* In other cases vma_area->premmaped_addr must be used.
* This hack is required, because vma_area isn't tranfered in restorer and
* shmid is used to determing which vma-s are cowed.
*/
#define vma_premmaped_start(vma) ((vma)->shmid)
static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
{
return addr >= (unsigned long)vma->e->start &&
addr < (unsigned long)vma->e->end;
}
#endif /* __CR_VMA_H__ */