From d707c4062d9d8d1443646ba3681c49b404dd24ad Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 23 Jul 2014 09:16:11 -0500 Subject: [PATCH] kpatch: add unload --all command This may end up being useful in the distro patch module upgrade path. If the core module also needs updating, we can first do "kpatch unload --all" and "rmmod kpatch" before doing "kpatch load" of the new patch module. --- kpatch/kpatch | 14 ++++++++++++-- man/kpatch.1 | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kpatch/kpatch b/kpatch/kpatch index 3785df3..0df5cda 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -42,6 +42,7 @@ usage () { usage_cmd "load --all" "load all installed patch modules into the running kernel" usage_cmd "load " "load patch module into the running kernel" usage_cmd "replace " "load patch module into the running kernel, replacing all other modules" + usage_cmd "unload --all" "unload all patch modules from the running kernel" usage_cmd "unload " "unload patch module from the running kernel" echo >&2 usage_cmd "info " "show information about a patch module" @@ -164,8 +165,17 @@ case "$1" in "unload") [[ "$#" -ne 2 ]] && usage - [[ $2 =~ ^- ]] && usage - unload_module "$(basename $2)" || die "failed to unload module $2" + case "$2" in + "--all") + for module in /sys/kernel/kpatch/patches/*; do + [[ -e $module ]] || continue + unload_module $(basename $module) || die "failed to unload module $module" + done + ;; + *) + unload_module "$(basename $2)" || die "failed to unload module $2" + ;; + esac ;; "install") diff --git a/man/kpatch.1 b/man/kpatch.1 index afee613..d8db1b6 100644 --- a/man/kpatch.1 +++ b/man/kpatch.1 @@ -26,6 +26,9 @@ load replace load patch module into the running kernel, replacing all other modules +unload --all + unload all patch modules from the running kernel + unload unload patch module from the running kernel