[CRIU] [PATCH 03/10] zdtm/vdso01: separate handlers calling traversal
Dmitry Safonov
dsafonov at virtuozzo.com
Thu Feb 16 08:20:38 PST 2017
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
test/zdtm/static/vdso01.c | 52 +++++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/test/zdtm/static/vdso01.c b/test/zdtm/static/vdso01.c
index fe52d1947702..9572c174c162 100644
--- a/test/zdtm/static/vdso01.c
+++ b/test/zdtm/static/vdso01.c
@@ -359,59 +359,57 @@ static int vdso_time_handler(void *func)
return 0;
}
-int main(int argc, char *argv[])
+static int call_handlers(struct vdso_symtable *symtable)
{
typedef int (handler_t)(void *func);
-
- struct vdso_symtable symtable;
- size_t i;
-
handler_t *handlers[VDSO_SYMBOL_MAX] = {
[VDSO_SYMBOL_CLOCK_GETTIME] = vdso_clock_gettime_handler,
[VDSO_SYMBOL_GETCPU] = vdso_getcpu_handler,
[VDSO_SYMBOL_GETTIMEOFDAY] = vdso_gettimeofday_handler,
[VDSO_SYMBOL_TIME] = vdso_time_handler,
};
+ size_t i;
- test_init(argc, argv);
-
- if (vdso_fill_self_symtable(&symtable)) {
- pr_perror("Faied to parse vdso");
- return -1;
- }
-
- for (i = 0; i < ARRAY_SIZE(symtable.symbols); i++) {
- struct vdso_symbol *s = &symtable.symbols[i];
+ for (i = 0; i < ARRAY_SIZE(symtable->symbols); i++) {
+ struct vdso_symbol *s = &symtable->symbols[i];
handler_t *func;
if (vdso_symbol_empty(s) || i > ARRAY_SIZE(handlers))
continue;
func = handlers[i];
- if (func((void *)(s->offset + symtable.vma_start))) {
+ if (func((void *)(s->offset + symtable->vma_start))) {
pr_perror("Handler error");
return -1;
}
}
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ struct vdso_symtable symtable;
+
+ test_init(argc, argv);
+
+ if (vdso_fill_self_symtable(&symtable)) {
+ pr_perror("Faied to parse vdso");
+ return -1;
+ }
+
+ if (call_handlers(&symtable))
+ return -1;
+
test_daemon();
test_waitsig();
/*
* After restore the vDSO must remain in old place.
*/
- for (i = 0; i < ARRAY_SIZE(symtable.symbols); i++) {
- struct vdso_symbol *s = &symtable.symbols[i];
- handler_t *func;
-
- if (vdso_symbol_empty(s) || i > ARRAY_SIZE(handlers))
- continue;
- func = handlers[i];
-
- if (func((void *)(s->offset + symtable.vma_start))) {
- fail("Handler error");
- return -1;
- }
+ if (call_handlers(&symtable)) {
+ fail("Failed to call vdso handlers from symtable after C/R");
+ return -1;
}
pass();
--
2.11.1
More information about the CRIU
mailing list