From 6a17d8cf49aaaccc76e232c6d22b01ed785b5ea0 Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Wed, 16 Aug 2017 10:32:25 +0300 Subject: [PATCH] check/servise: use cached kdat values for features check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The kerndat_init() is now called before the jump to action handler. This allows us to directly use kdat without calling to the corresponding kerndat_*() methods. ✓ travis-ci: success for lazy-pages: update checks for availability of userfaultfd (rev3) Signed-off-by: Mike Rapoport Signed-off-by: Pavel Emelyanov --- criu/cr-check.c | 18 ------------------ criu/cr-service.c | 23 ++++------------------- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/criu/cr-check.c b/criu/cr-check.c index 9ab43652b..ef706bf7b 100644 --- a/criu/cr-check.c +++ b/criu/cr-check.c @@ -676,9 +676,6 @@ static int check_ptrace_dump_seccomp_filters(void) static int check_mem_dirty_track(void) { - if (kerndat_get_dirty_track() < 0) - return -1; - if (!kdat.has_dirty_track) { pr_warn("Dirty tracking is OFF. Memory snapshot will not work.\n"); return -1; @@ -772,9 +769,6 @@ static int check_aio_remap(void) static int check_fdinfo_lock(void) { - if (kerndat_fdinfo_has_lock()) - return -1; - if (!kdat.has_fdinfo_lock) { pr_err("fdinfo doesn't contain the lock field\n"); return -1; @@ -931,12 +925,6 @@ out: static int check_tcp_halt_closed(void) { - int ret; - - ret = kerndat_tcp_repair(); - if (ret < 0) - return -1; - if (!kdat.has_tcp_half_closed) { pr_err("TCP_REPAIR can't be enabled for half-closed sockets\n"); return -1; @@ -1023,9 +1011,6 @@ static int check_userns(void) static int check_loginuid(void) { - if (kerndat_loginuid() < 0) - return -1; - if (kdat.luid != LUID_FULL) { pr_warn("Loginuid restore is OFF.\n"); return -1; @@ -1048,9 +1033,6 @@ static int check_compat_cr(void) static int check_uffd(void) { - if (kerndat_uffd()) - return -1; - if (!kdat.has_uffd) { pr_err("UFFD is not supported\n"); return -1; diff --git a/criu/cr-service.c b/criu/cr-service.c index 375b03533..84d7eb2be 100644 --- a/criu/cr-service.c +++ b/criu/cr-service.c @@ -886,22 +886,11 @@ static int handle_feature_check(int sk, CriuReq * msg) setproctitle("feature-check --rpc"); if ((msg->features->has_mem_track == 1) && - (msg->features->mem_track == true)) { - - feat.mem_track = true; - ret = kerndat_get_dirty_track(); - - if (ret) - feat.mem_track = false; - - if (!kdat.has_dirty_track) - feat.mem_track = false; - } + (msg->features->mem_track == true)) + feat.mem_track = kdat.has_dirty_track; if ((msg->features->has_lazy_pages == 1) && - (msg->features->lazy_pages == true)) { - ret = kerndat_uffd(); - + (msg->features->lazy_pages == true)) /* * Not checking for specific UFFD features yet. * If no error is returned it is probably @@ -909,11 +898,7 @@ static int handle_feature_check(int sk, CriuReq * msg) * be extended in the future for a more detailed * UFFD feature check. */ - if (ret || !kdat.has_uffd) - feat.lazy_pages = false; - else - feat.lazy_pages = true; - } + feat.lazy_pages = kdat.has_uffd; resp.features = &feat; resp.type = msg->type;