Permalink
Browse files

criu: Fault injection core

This patch(set) is inspired by similar from Andrey Vagin sent
sime time earlier.

The major idea is to artificially fail criu dump or restore at
specific places and let zdtm tests check whether failed dump
or restore resulted in anything bad.

This particular patch introduces the ability to tell criu "fail
at X point". Each point is specified with a integer constant
and with the next patches there will appear places over the
code checking for specific fail code being set and failing.

Two points are introduced -- early on dump, right after loading
the parasite and right after creation of the root task.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
  • Loading branch information...
xemul committed Oct 13, 2015
1 parent c405304 commit 68baf8e77d4321cfbc072f10ddd5e99c6db4dd51
Showing with 58 additions and 1 deletion.
  1. +1 −0 Makefile.crtools
  2. +6 −0 cr-dump.c
  3. +6 −1 cr-restore.c
  4. +4 −0 crtools.c
  5. +22 −0 fault-injection.c
  6. +19 −0 include/fault-injection.h
View
@@ -75,6 +75,7 @@ obj-y += plugin.o
obj-y += cr-errno.o
obj-y += pie/pie-relocs.o
obj-y += seize.o
obj-y += fault-injection.o
obj-y += pie/util-fd.o
obj-y += pie/util.o
View
@@ -81,6 +81,7 @@
#include "lsm.h"
#include "seccomp.h"
#include "seize.h"
#include "fault-injection.h"
#include "asm/dump.h"
@@ -1195,6 +1196,11 @@ static int dump_one_task(struct pstree_item *item)
goto err;
}
if (fault_injected(FI_DUMP_EARLY)) {
pr_info("fault: CRIU sudden detach\n");
BUG();
}
if (root_ns_mask & CLONE_NEWPID && root_item == item) {
int pfd;
View
@@ -76,7 +76,7 @@
#include "security.h"
#include "lsm.h"
#include "seccomp.h"
#include "fault-injection.h"
#include "parasite-syscall.h"
#include "protobuf.h"
@@ -1531,6 +1531,11 @@ static int restore_task_with_children(void *_arg)
if (prepare_sigactions() < 0)
goto err_fini_mnt;
if (fault_injected(FI_RESTORE_ROOT_ONLY)) {
pr_info("fault: Restore root task failure!\n");
BUG();
}
if (create_children_and_session())
goto err_fini_mnt;
View
@@ -40,6 +40,7 @@
#include "action-scripts.h"
#include "security.h"
#include "irmap.h"
#include "fault-injection.h"
#include "setproctitle.h"
@@ -257,6 +258,9 @@ int main(int argc, char *argv[], char *envp[])
BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
if (fault_injection_init())
return 1;
cr_pb_init();
if (restrict_uid(getuid(), getgid()))
return 1;
View
@@ -0,0 +1,22 @@
#include <stdlib.h>
#include "fault-injection.h"
enum faults fi_strategy;
int fault_injection_init()
{
char *val;
int strat;
val = getenv("CRIU_FAULT");
if (val == NULL)
return 0;
strat = atoi(val);
if (strat <= 0 || strat >= FI_MAX)
return -1;
fi_strategy = strat;
return 0;
}
View
@@ -0,0 +1,19 @@
#ifndef __CR_FAULT_INJECTION_H__
#define __CR_FAULT_INJECTION_H__
#include <stdbool.h>
enum faults {
FI_NONE = 0,
FI_DUMP_EARLY,
FI_RESTORE_ROOT_ONLY,
FI_MAX,
};
extern enum faults fi_strategy;
extern int fault_injection_init(void);
static inline bool fault_injected(enum faults f)
{
return fi_strategy == f;
}
#endif

0 comments on commit 68baf8e

Please sign in to comment.