From ed31d7af3dccdeb08b63b381825b80eb8911358c Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Mon, 21 Apr 2014 21:38:00 -0500 Subject: [PATCH 1/2] kpatch: look for core module in git dir Allow "kpatch load" to find the core module when kpatch is run directly from the git tree. This gives the user the option to use the kpatch utility directly without having to do a "make install". --- kpatch/kpatch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kpatch/kpatch b/kpatch/kpatch index 370d66c..ce3dc04 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -26,6 +26,7 @@ KERNELRELEASE="$(uname -r)" SYSDIR="/usr/lib/kpatch/$KERNELRELEASE" USERDIR="/var/lib/kpatch/$KERNELRELEASE" +SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" usage () { echo "usage: kpatch []" >&2 @@ -72,6 +73,9 @@ find_module () { } find_core_module() { + COREMOD="$SCRIPTDIR"/../kmod/core/kpatch.ko + [[ -f "$COREMOD" ]] && return + COREMOD="/usr/local/lib/modules/$(uname -r)/kpatch/kpatch.ko" [[ -f "$COREMOD" ]] && return From d1d79084a3498acc936b7aa25cd3df59da7c316b Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Mon, 21 Apr 2014 21:43:57 -0500 Subject: [PATCH 2/2] readme: recommend use of the kpatch utility The kpatch utility is now user friendly enough that it can be used instead of direct insmods. We should encourage people to use it, since we will soon be adding user space functionality above and beyond insmod/rmmod when loading and unloading. --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 49a5e1e..f18d117 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,13 @@ Compile kpatch: make -Install kpatch to /usr/local: +OPTIONAL: Install kpatch to /usr/local: sudo make install +Alternatively, the kpatch and kpatch-build scripts can be run directly from the +git tree. + Quick start ----------- @@ -51,10 +54,6 @@ Quick start kernel on any distribution, the "kpatch-build" command currently only works on Fedora.* -Load the kpatch core module: - - sudo insmod /usr/local/lib/modules/$(uname -r)/kpatch/kpatch.ko - Make a source patch against the kernel tree: # from a kernel git tree: @@ -67,7 +66,7 @@ Build the patch module: This outputs a patch module named `kpatch-foo.ko` in the current directory. Now apply it to the running kernel: - sudo insmod kpatch-foo.ko + sudo kpatch load kpatch-foo.ko Done! The kernel is now patched.