Blame SOURCES/0003-kpatch-script-don-t-fail-if-module-already-loaded-en.patch

338c91
From 1d2dffec7a6fad4a8daed9340cd42aada856d03f Mon Sep 17 00:00:00 2001
338c91
From: Joe Lawrence <joe.lawrence@redhat.com>
338c91
Date: Wed, 19 Jun 2019 15:29:43 -0400
338c91
Subject: [PATCH] kpatch script: don't fail if module already loaded+enabled
338c91
338c91
For "kpatch load" invocations, don't set failing return status if the
338c91
kpatch module is already loaded and enabled.  Make note of the existing
338c91
livepatch module and then verify that is has completed its transition
338c91
before continuing.  This allows the user to more gracefully re-run
338c91
"kpatch load" commands to pick up new kpatch modules.
338c91
338c91
Fixes: #979
338c91
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
338c91
---
338c91
 kpatch/kpatch | 44 ++++++++++++++++++++++----------------------
338c91
 1 file changed, 22 insertions(+), 22 deletions(-)
338c91
338c91
diff --git a/kpatch/kpatch b/kpatch/kpatch
338c91
index 328f1197259d..8ea6c80ca2d3 100755
338c91
--- a/kpatch/kpatch
338c91
+++ b/kpatch/kpatch
338c91
@@ -314,30 +314,30 @@ load_module () {
338c91
 				die "error: cannot re-enable patch module $modname, cannot verify checksum match"
338c91
 			fi
338c91
 		else
338c91
-			die "error: module named $modname already loaded and enabled"
338c91
+			echo "module named $modname already loaded and enabled"
338c91
 		fi
338c91
-	fi
338c91
+	else
338c91
+		echo "loading patch module: $module"
338c91
+		local i=0
338c91
+		while true; do
338c91
+			out="$(LC_ALL=C insmod "$module" 2>&1)"
338c91
+			[[ -z "$out" ]] && break
338c91
+			echo "$out" 1>&2
338c91
+			[[ ! "$out" =~ "Device or resource busy" ]] &&
338c91
+				die "failed to load module $module"
338c91
 
338c91
-	echo "loading patch module: $module"
338c91
-	local i=0
338c91
-	while true; do
338c91
-		out="$(LC_ALL=C insmod "$module" 2>&1)"
338c91
-		[[ -z "$out" ]] && break
338c91
-		echo "$out" 1>&2
338c91
-		[[ ! "$out" =~ "Device or resource busy" ]] &&
338c91
-			die "failed to load module $module"
338c91
-
338c91
-		# "Device or resource busy" means the activeness safety check
338c91
-		# failed.  Retry in a few seconds.
338c91
-		i=$((i+1))
338c91
-		if [[ $i -eq $MAX_LOAD_ATTEMPTS ]]; then
338c91
-			die "failed to load module $module"
338c91
-			break
338c91
-		else
338c91
-			warn "retrying..."
338c91
-			sleep $RETRY_INTERVAL
338c91
-		fi
338c91
-	done
338c91
+			# "Device or resource busy" means the activeness safety check
338c91
+			# failed.  Retry in a few seconds.
338c91
+			i=$((i+1))
338c91
+			if [[ $i -eq $MAX_LOAD_ATTEMPTS ]]; then
338c91
+				die "failed to load module $module"
338c91
+				break
338c91
+			else
338c91
+				warn "retrying..."
338c91
+				sleep $RETRY_INTERVAL
338c91
+			fi
338c91
+		done
338c91
+	fi
338c91
 
338c91
 	if ! wait_for_patch_transition "$modname" ; then
338c91
 		echo "module $modname did not complete its transition, unloading..."
338c91
-- 
338c91
2.21.0
338c91