[CRIU] [PATCH 09/10] restorer/fault: add fault-injection into restorer
Dmitry Safonov
dsafonov at virtuozzo.com
Thu Feb 16 08:20:44 PST 2017
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/cr-restore.c | 1 +
criu/include/fault-injection.h | 19 +++++++++++++++----
criu/include/restorer.h | 3 +++
criu/pie/restorer.c | 7 +++++++
4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 47e01a62a9d7..7aabb6c5f53a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -3090,6 +3090,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
}
task_args->breakpoint = &rsti(current)->breakpoint;
+ task_args->fault_strategy = fi_strategy;
sigemptyset(&blockmask);
sigaddset(&blockmask, SIGCHLD);
diff --git a/criu/include/fault-injection.h b/criu/include/fault-injection.h
index 2b23f54bdbc2..5b3313667ab2 100644
--- a/criu/include/fault-injection.h
+++ b/criu/include/fault-injection.h
@@ -18,10 +18,7 @@ enum faults {
FI_MAX,
};
-extern enum faults fi_strategy;
-extern int fault_injection_init(void);
-
-static inline bool fault_injected(enum faults f)
+static inline bool __fault_injected(enum faults f, enum faults fi_strategy)
{
/*
* Temporary workaround for Xen guests. Breakpoints degrade
@@ -33,4 +30,18 @@ static inline bool fault_injected(enum faults f)
return fi_strategy == f;
}
+
+#ifndef CR_NOGLIBC
+
+extern enum faults fi_strategy;
+#define fault_injected(f) __fault_injected(f, fi_strategy)
+
+extern int fault_injection_init(void);
+
+#else /* CR_NOGLIBC */
+
+extern bool fault_injected(enum faults f);
+
+#endif
+
#endif
diff --git a/criu/include/restorer.h b/criu/include/restorer.h
index 23c7e24b81ee..715640d122d8 100644
--- a/criu/include/restorer.h
+++ b/criu/include/restorer.h
@@ -18,6 +18,7 @@
#include "timerfd.h"
#include "shmem.h"
#include "parasite-vdso.h"
+#include "fault-injection.h"
#include <time.h>
@@ -186,6 +187,8 @@ struct task_restore_args {
unsigned long vdso_rt_parked_at; /* safe place to keep vdso */
#endif
void **breakpoint;
+
+ enum faults fault_strategy;
} __aligned(64);
/*
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 7783ce2f16e9..1d387b6e7d04 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -64,6 +64,11 @@ static pid_t *helpers;
static int n_helpers;
static pid_t *zombies;
static int n_zombies;
+static enum faults fi_strategy;
+bool fault_injected(enum faults f)
+{
+ return __fault_injected(f, fi_strategy);
+}
/*
* These are stubs for std compel plugin.
@@ -1143,6 +1148,8 @@ long __export_restore_task(struct task_restore_args *args)
vdso_rt_size = args->vdso_rt_size;
#endif
+ fi_strategy = args->fault_strategy;
+
task_entries_local = args->task_entries;
helpers = args->helpers;
n_helpers = args->helpers_n;
--
2.11.1
More information about the CRIU
mailing list