Commit 7dfc2128 authored by Pavel Emelyanov's avatar Pavel Emelyanov

restore: Merge self vmas alltogether

When getting hint for restorer blob we scan the list of
vmas in criu address space. Since these vmas are only
required to find holes, we can merge vmas alltogether
and make restorer_get_vma_hint's work easier.

Reduces list of items in small zdtm tests from 71 to 9.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 62838976
......@@ -383,6 +383,7 @@ static int vma_get_mapfile(char *fname, struct vma_area *vma, DIR *mfd,
int parse_self_maps_lite(struct vm_area_list *vms)
{
FILE *maps;
struct vma_area *prev = NULL;
vm_area_list_init(vms);
......@@ -395,17 +396,31 @@ int parse_self_maps_lite(struct vm_area_list *vms)
while (fgets(buf, BUF_SIZE, maps) != NULL) {
struct vma_area *vma;
char *end;
unsigned long s, e;
vma = alloc_vma_area();
if (!vma) {
fclose(maps);
return -1;
}
s = strtoul(buf, &end, 16);
e = strtoul(end + 1, NULL, 16);
vma->e->start = strtoul(buf, &end, 16);
vma->e->end = strtoul(end + 1, NULL, 16);
list_add_tail(&vma->list, &vms->h);
vms->nr++;
if (prev && prev->e->end == s)
/*
* This list is needed for one thing only -- to
* get the idea of what parts of current address
* space are busy. So merge them alltogether.
*/
prev->e->end = e;
else {
vma = alloc_vma_area();
if (!vma) {
fclose(maps);
return -1;
}
vma->e->start = s;
vma->e->end = e;
list_add_tail(&vma->list, &vms->h);
vms->nr++;
prev = vma;
}
pr_debug("Parsed %"PRIx64"-%"PRIx64" vma\n", vma->e->start, vma->e->end);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment