5c5ee9
kpatch: clarify that "kpatch unload" isn't supported
5c5ee9
5c5ee9
Add a user-prompt to the kpatch unload subcommand and make a similiar
5c5ee9
mention in the manual page.
5c5ee9
5c5ee9
Provide an undocumented force option so that QE and dev scripts can
5c5ee9
still run unload kpatch modules from scripts.
5c5ee9
5c5ee9
RHEL-only.
5c5ee9
5c5ee9
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
5c5ee9
diff -Nupr kpatch-0.6.1.old/kpatch/kpatch kpatch-0.6.1/kpatch/kpatch
3cf1e4
--- kpatch-0.9.2.old/kpatch/kpatch	2019-08-28 10:35:01.191259434 -0400
3cf1e4
+++ kpatch-0.9.2/kpatch/kpatch	2019-08-28 16:11:13.067926576 -0400
5c5ee9
@@ -49,8 +49,8 @@ usage () {
5c5ee9
 	echo >&2
5c5ee9
 	usage_cmd "load --all" "load all installed patch modules into the running kernel"
5c5ee9
 	usage_cmd "load <module>" "load patch module into the running kernel"
5c5ee9
-	usage_cmd "unload --all" "unload all patch modules from the running kernel"
5c5ee9
-	usage_cmd "unload <module>" "unload patch module from the running kernel"
5c5ee9
+	usage_cmd "unload --all (UNSUPPORTED)" "unload all patch modules from the running kernel"
5c5ee9
+	usage_cmd "unload <module> (UNSUPPORTED)" "unload patch module from the running kernel"
5c5ee9
 	echo >&2
5c5ee9
 	usage_cmd "info <module>" "show information about a patch module"
5c5ee9
 	echo >&2
5c5ee9
@@ -71,6 +71,16 @@ die() {
5c5ee9
 	exit 1
5c5ee9
 }
5c5ee9
 
5c5ee9
+confirm_prompt() {
5c5ee9
+	local prompt="$1"
5c5ee9
+	local answer
5c5ee9
+	while true; do
5c5ee9
+		read -rp "$prompt [Y/N] " answer
5c5ee9
+		[[ $answer == 'Y' || $answer == 'y' ]] && return 0
5c5ee9
+		[[ $answer == 'N' || $answer == 'n' ]] && return 1
5c5ee9
+	done
5c5ee9
+}
5c5ee9
+
5c5ee9
 __find_module () {
5c5ee9
 	MODULE="$1"
5c5ee9
 	[[ -f "$MODULE" ]] && return
5c5ee9
@@ -406,6 +416,19 @@ unset MODULE
5c5ee9
 init_sysfs_var
5c5ee9
 
5c5ee9
 [[ "$#" -lt 1 ]] && usage
5c5ee9
+
5c5ee9
+# RHEL-specific support options
5c5ee9
+case "$1" in
5c5ee9
+"force")
5c5ee9
+	# For scripting purposes, support "kpatch force unload".
5c5ee9
+	# Shift out the "force" to avoid the user-prompt check below.
5c5ee9
+	shift
5c5ee9
+	;;
5c5ee9
+"unload")
5c5ee9
+	confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1
5c5ee9
+	;;
5c5ee9
+esac
5c5ee9
+
5c5ee9
 case "$1" in
5c5ee9
 "load")
5c5ee9
 	[[ "$#" -ne 2 ]] && usage
5c5ee9
diff -Nupr kpatch-0.6.1.old/man/kpatch.1 kpatch-0.6.1/man/kpatch.1
3cf1e4
--- kpatch-0.9.2.old/man/kpatch.1	2019-08-28 10:35:01.191259434 -0400
3cf1e4
+++ kpatch-0.9.2/man/kpatch.1	2019-08-28 14:51:23.268198897 -0400
5c5ee9
@@ -23,10 +23,10 @@ load --all
5c5ee9
 load <module>
5c5ee9
        load patch module into the running kernel
5c5ee9
 
5c5ee9
-unload --all
5c5ee9
+unload --all (UNSUPPORTED)
5c5ee9
        unload all patch modules from the running kernel
5c5ee9
 
5c5ee9
-unload <module>
5c5ee9
+unload <module> (UNSUPPORTED)
5c5ee9
        unload patch module from the running kernel
5c5ee9
 
5c5ee9
 info <module>