Commit c94fb7d0 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

fault-injection: Add FI_HUGE_ANON_SHMEM_ID type

To test if we can survive with shmid more than 4 bytes
long in image formats.

Without the fix for shmid

 | [root@uranus criu] test/zdtm.py run -t zdtm/static/maps01 --fault 132 -f h -k always
 | === Run 1/1 ================ zdtm/static/maps01
 |
 | ========================= Run zdtm/static/maps01 in h ==========================
 | Start test
 | Test is SUID
 | ./maps01 --pidfile=maps01.pid --outfile=maps01.out
 | Run criu dump
 | Forcing 132 fault
 | Run criu restore
 | Forcing 132 fault
 | =[log]=> dump/zdtm/static/maps01/36/1/restore.log
 | ------------------------ grep Error ------------------------
 | (00.016464)     37: Opening 0x007f39c04b5000-0x007f3a004b5000 0000000000000000 (101) vma
 | (00.016465)     37: Search for 0x007f39c04b5000 shmem 0x10118e915 0x7f97f7ae4ae8/36
 | (00.016470)     37: Waiting for the 10118e915 shmem to appear
 | (00.016479)     36: No pagemap-shmem-18409749.img image
 | (00.016481)     36: Error (criu/shmem.c:559): Can't restore shmem content
 | (00.016501)     36: Error (criu/mem.c:1208): `- Can't open vma
 | (00.016552) Error (criu/cr-restore.c:2449): Restoring FAILED.
 | ------------------------ ERROR OVER ------------------------

And with the fix

 | [root@uranus criu] test/zdtm.py run -t zdtm/static/maps01 --fault 132 -f h -k always
 | === Run 1/1 ================ zdtm/static/maps01
 |
 | ========================= Run zdtm/static/maps01 in h ==========================
 | Start test
 | Test is SUID
 | ./maps01 --pidfile=maps01.pid --outfile=maps01.out
 | Run criu dump
 | Forcing 132 fault
 | Run criu restore
 | Forcing 132 fault
 | Send the 15 signal to  36
 | Wait for zdtm/static/maps01(36) to die for 0.100000
 | ========================= Test zdtm/static/maps01 PASS =========================
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 5785dbd9
......@@ -16,6 +16,7 @@ enum faults {
FI_NO_MEMFD = 129,
FI_NO_BREAKPOINTS = 130,
FI_PARTIAL_PAGES = 131,
FI_HUGE_ANON_SHMEM_ID = 132,
FI_MAX,
};
......@@ -32,6 +33,8 @@ static inline bool __fault_injected(enum faults f, enum faults fi_strategy)
return fi_strategy == f;
}
#define FI_HUGE_ANON_SHMEM_ID_BASE (0xfffffffflu)
#ifndef CR_NOGLIBC
extern enum faults fi_strategy;
......
......@@ -40,6 +40,7 @@
#include "cgroup-props.h"
#include "timerfd.h"
#include "path.h"
#include "fault-injection.h"
#include "protobuf.h"
#include "images/fdinfo.pb-c.h"
......@@ -310,8 +311,12 @@ static int vma_get_mapfile_user(const char *fname, struct vma_area *vma,
vma->e->status |= VMA_ANON_SHARED;
vma->e->shmid = vfi->ino;
if (!strncmp(fname, "/SYSV", 5))
if (!strncmp(fname, "/SYSV", 5)) {
vma->e->status |= VMA_AREA_SYSVIPC;
} else {
if (fault_injected(FI_HUGE_ANON_SHMEM_ID))
vma->e->shmid += FI_HUGE_ANON_SHMEM_ID_BASE;
}
return 0;
}
......@@ -598,6 +603,9 @@ static int handle_vma(pid_t pid, struct vma_area *vma_area,
if (!strncmp(file_path, "/SYSV", 5)) {
pr_info("path: %s\n", file_path);
vma_area->e->status |= VMA_AREA_SYSVIPC;
} else {
if (fault_injected(FI_HUGE_ANON_SHMEM_ID))
vma_area->e->shmid += FI_HUGE_ANON_SHMEM_ID_BASE;
}
} else {
if (vma_area->e->flags & MAP_PRIVATE)
......
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