From c585a3744029d710d57b56dadf88fc524ee0fdc4 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Mon, 19 Nov 2018 17:23:53 +0900 Subject: [PATCH] move mcoverlayfs kernel version check from mcexec.c to configure While we are here: - fix uname -r (single quote?!) - add compat for rhel8 (el kernel and version is 4.18) - also remove linux version check in mcreboot.sh, trust configure check Change-Id: I14726d4374b0dfd941640096044ea1d5d88bfcb8 --- arch/x86_64/tools/mcreboot-smp-x86.sh.in | 36 +++++--------------- configure | 43 ++++++++++++++++++++++-- configure.ac | 40 ++++++++++++++++++++-- executer/kernel/mcoverlayfs/Makefile.in | 41 ++-------------------- executer/user/mcexec.c | 24 ------------- 5 files changed, 89 insertions(+), 95 deletions(-) diff --git a/arch/x86_64/tools/mcreboot-smp-x86.sh.in b/arch/x86_64/tools/mcreboot-smp-x86.sh.in index 064bc25b..cacd2cad 100644 --- a/arch/x86_64/tools/mcreboot-smp-x86.sh.in +++ b/arch/x86_64/tools/mcreboot-smp-x86.sh.in @@ -137,32 +137,32 @@ error_exit() { fi ;& mcos_sys_mounted) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then umount /tmp/mcos/mcos0_sys fi ;& mcos_proc_mounted) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then umount /tmp/mcos/mcos0_proc fi ;& mcoverlayfs_loaded) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then rmmod mcoverlay 2>/dev/null fi ;& linux_proc_bind_mounted) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then umount /tmp/mcos/linux_proc fi ;& tmp_mcos_mounted) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then umount /tmp/mcos fi ;& tmp_mcos_created) - if [ "$enable_mcoverlay" == "yes" ]; then + if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then rm -rf /tmp/mcos fi ;& @@ -239,26 +239,6 @@ if [ "${release}" == "${rhel_release}" ]; then rhel_release=""; fi -enable_mcoverlay="no" - -if [ "${ENABLE_MCOVERLAYFS}" == "yes" ]; then - if [ "${rhel_release}" == "" ]; then - if [ ${linux_version_code} -ge 262144 -a ${linux_version_code} -lt 262400 ]; then - enable_mcoverlay="yes" - fi - if [ ${linux_version_code} -ge 263680 -a ${linux_version_code} -lt 263936 ]; then - enable_mcoverlay="yes" - fi - else - if [ ${linux_version_code} -eq 199168 -a ${rhel_release} -ge 327 -a ${rhel_release} -le 862 ]; then - enable_mcoverlay="yes" - fi - if [ ${linux_version_code} -ge 262144 -a ${linux_version_code} -lt 262400 ]; then - enable_mcoverlay="yes" - fi - fi -fi - # Figure out CPUs if not requested by user if [ "$cpus" == "" ]; then # Get the number of CPUs on NUMA node 0 @@ -274,7 +254,7 @@ if [ "$cpus" == "" ]; then fi # Remove mcoverlay if loaded -if [ "$enable_mcoverlay" == "yes" ]; then +if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then ${SBINDIR}/mcoverlay-destroy.sh ret=$? if [ $ret -ne 0 ]; then @@ -481,7 +461,7 @@ if ! chown ${chown_option} /dev/mcd* /dev/mcos*; then fi # Overlay /proc, /sys with McKernel specific contents -if [ "$enable_mcoverlay" == "yes" ]; then +if [ "$ENABLE_MCOVERLAYFS" == "yes" ]; then ${SBINDIR}/mcoverlay-create.sh ret=$? if [ $ret -ne 0 ]; then diff --git a/configure b/configure index 5918ac93..183af782 100755 --- a/configure +++ b/configure @@ -631,6 +631,7 @@ IHK_VERSION WITH_SYSCALL_INTERCEPT ENABLE_QLMPI ENABLE_RUSAGE +MCOVERLAYFS_MODULE ENABLE_MCOVERLAYFS LDFLAGS_SYSCALL_INTERCEPT CPPFLAGS_SYSCALL_INTERCEPT @@ -3804,7 +3805,7 @@ fi case "X$WITH_UNAME_R" in Xyes | Xno | X) - WITH_UNAME_R='`uname -r`' + WITH_UNAME_R="`uname -r`" ;; esac @@ -4750,9 +4751,44 @@ $as_echo "#define ENABLE_MCOVERLAYFS 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: mcoverlayfs is enabled" >&5 $as_echo "$as_me: mcoverlayfs is enabled" >&6;} + + IFS=. read LINUX_VERSION_MAJOR LINUX_VERSION_MINOR LINUX_VERSION_PATCH _ <= 262144 && LINUX_VERSION_CODE < 262400))) + MCOVERLAYFS_MODULE=linux-4.0.9;; + # 4.6.0-4.7.0 + $((LINUX_VERSION_CODE >= 263680 && LINUX_VERSION_CODE < 263936))) + MCOVERLAYFS_MODULE=linux-4.6.7;; + # 4.18.0-4.20.0 + $((LINUX_VERSION_CODE >= 266752 && LINUX_VERSION_CODE < 267264))) + MCOVERLAYFS_MODULE=linux-4.18.14;; + *) + as_fn_error $? "Your kernel version has no known mcoverlayfs module" "$LINENO" 5;; + esac + fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: mcoverlayfs is disabled" >&5 -$as_echo "$as_me: mcoverlayfs is disabled" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mcoverlayfs is disabled. You will not be able to run anything." >&5 +$as_echo "$as_me: WARNING: mcoverlayfs is disabled. You will not be able to run anything." >&2;} fi if test "x$ENABLE_QLMPI" = "xyes" ; then @@ -4892,6 +4928,7 @@ fi + ac_config_headers="$ac_config_headers config.h" diff --git a/configure.ac b/configure.ac index 3035fe4a..40fac2da 100644 --- a/configure.ac +++ b/configure.ac @@ -220,7 +220,7 @@ AC_ARG_WITH([uname_r], case "X$WITH_UNAME_R" in Xyes | Xno | X) - WITH_UNAME_R='`uname -r`' + WITH_UNAME_R="`uname -r`" ;; esac @@ -450,8 +450,43 @@ fi if test "x$ENABLE_MCOVERLAYFS" = "xyes" ; then AC_DEFINE([ENABLE_MCOVERLAYFS],[1],[whether mcoverlayfs is enabled]) AC_MSG_NOTICE([mcoverlayfs is enabled]) + + IFS=. read LINUX_VERSION_MAJOR LINUX_VERSION_MINOR LINUX_VERSION_PATCH _ <= 262144 && LINUX_VERSION_CODE < 262400))) + MCOVERLAYFS_MODULE=linux-4.0.9;; + # 4.6.0-4.7.0 + $((LINUX_VERSION_CODE >= 263680 && LINUX_VERSION_CODE < 263936))) + MCOVERLAYFS_MODULE=linux-4.6.7;; + # 4.18.0-4.20.0 + $((LINUX_VERSION_CODE >= 266752 && LINUX_VERSION_CODE < 267264))) + MCOVERLAYFS_MODULE=linux-4.18.14;; + *) + AC_MSG_ERROR([Your kernel version has no known mcoverlayfs module]);; + esac + fi else - AC_MSG_NOTICE([mcoverlayfs is disabled]) + AC_MSG_WARN([mcoverlayfs is disabled. You will not be able to run anything.]) fi if test "x$ENABLE_QLMPI" = "xyes" ; then @@ -536,6 +571,7 @@ AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS_SYSCALL_INTERCEPT) AC_SUBST(LDFLAGS_SYSCALL_INTERCEPT) AC_SUBST(ENABLE_MCOVERLAYFS) +AC_SUBST(MCOVERLAYFS_MODULE) AC_SUBST(ENABLE_RUSAGE) AC_SUBST(ENABLE_QLMPI) AC_SUBST(WITH_SYSCALL_INTERCEPT) diff --git a/executer/kernel/mcoverlayfs/Makefile.in b/executer/kernel/mcoverlayfs/Makefile.in index 87bc4e86..4e9decb7 100644 --- a/executer/kernel/mcoverlayfs/Makefile.in +++ b/executer/kernel/mcoverlayfs/Makefile.in @@ -1,43 +1,10 @@ ENABLE_MCOVERLAYFS=@ENABLE_MCOVERLAYFS@ -RELEASE=@UNAME_R@ - -MAJOR=$(shell echo ${RELEASE} | sed -e 's/^\([0-9]*\).*/\1/') -MINOR=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.\([0-9]*\).*/\1/') -PATCH=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.[0-9]*.\([0-9]*\).*/\1/') -LINUX_VERSION_CODE=$(shell expr \( ${MAJOR} \* 65536 \) + \( ${MINOR} \* 256 \) + ${PATCH}) -RHEL_RELEASE_TMP=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.[0-9]*.[0-9]*-\([0-9]*\).*/\1/') -RHEL_RELEASE=$(shell if [ "${RELEASE}" == "${RHEL_RELEASE_TMP}" ]; then echo ""; else echo ${RHEL_RELEASE_TMP}; fi) -BUILD_MODULE_TMP=$(shell if [ "${RHEL_RELEASE}" == "" ]; then echo "org"; else echo "rhel"; fi) -BUILD_MODULE=none -#$(info "LINUX_VERSION_CODE: ${LINUX_VERSION_CODE}, RHEL_RELEASE: ${RHEL_RELEASE}") -ifeq ($(ENABLE_MCOVERLAYFS),yes) -ifeq ($(BUILD_MODULE_TMP),org) -ifeq ($(BUILD_MODULE),none) -BUILD_MODULE=$(shell if [ ${LINUX_VERSION_CODE} -ge 262144 -a ${LINUX_VERSION_CODE} -lt 262400 ]; then echo "linux-4.0.9"; else echo "none"; fi) -endif -ifeq ($(BUILD_MODULE),none) -BUILD_MODULE=$(shell if [ ${LINUX_VERSION_CODE} -ge 263680 -a ${LINUX_VERSION_CODE} -lt 263936 ]; then echo "linux-4.6.7"; else echo "none"; fi) -endif -ifeq ($(BUILD_MODULE),none) -BUILD_MODULE=$(shell if [ ${LINUX_VERSION_CODE} -ge 266752 ]; then echo "linux-4.18.14"; else echo "none"; fi) -endif -endif -ifeq ($(BUILD_MODULE_TMP),rhel) -ifeq ($(BUILD_MODULE),none) -BUILD_MODULE=$(shell if [ ${LINUX_VERSION_CODE} -eq 199168 -a ${RHEL_RELEASE} -ge 327 -a ${RHEL_RELEASE} -le 862 ]; then echo "linux-3.10.0-327.36.1.el7"; else echo "none"; fi) -endif -ifeq ($(BUILD_MODULE),none) -BUILD_MODULE=$(shell if [ ${LINUX_VERSION_CODE} -ge 262144 -a ${LINUX_VERSION_CODE} -lt 262400 ]; then echo "linux-4.0.9"; else echo "none"; fi) -endif -endif -endif +MCOVERLAYFS_MODULE=@MCOVERLAYFS_MODULE@ .PHONY: clean install modules modules: -ifneq ($(BUILD_MODULE),none) - +@(cd $(BUILD_MODULE) && make modules) -endif + +@(cd $(MCOVERLAYFS_MODULE) && make modules) clean: @(cd linux-3.10.0-327.36.1.el7 && make clean) @@ -46,7 +13,5 @@ clean: @(cd linux-4.18.14 && make clean) install: -ifneq ($(BUILD_MODULE),none) - @(cd $(BUILD_MODULE); make install) -endif + @(cd $(MCOVERLAYFS_MODULE); make install) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 4ba26c5c..389233b8 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -153,30 +153,6 @@ int __glob_argc = -1; char **__glob_argv = 0; #endif -#ifdef ENABLE_MCOVERLAYFS -#undef ENABLE_MCOVERLAYFS - -// RedHat? -#ifdef RHEL_RELEASE_CODE - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) -#define ENABLE_MCOVERLAYFS 1 -#else -#error "ERROR: your Linux kernel version on RHEL is not supported" -#endif // LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) - -// Other distro? -#else -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0) -#define ENABLE_MCOVERLAYFS 1 -#endif // LINUX_VERSION_CODE == 4.0 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) -#define ENABLE_MCOVERLAYFS 1 -#endif // LINUX_VERSION_CODE == 4.6 - -#endif // RHEL_RELEASE_CODE -#endif // ENABLE_MCOVERLAYFS - typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t;