3 # Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
19 use Cwd
'abs_path', 'getcwd';
23 use lib
'KSPLICE_DATA_DIR';
26 my ($help, $wantversion, $debug) = (0, 0, 0);
27 GetOptions
("help|?" => \
$help,
28 "version" => \
$wantversion,
29 "verbose|v!" => \
$verbose,
30 "debug=i" => \
$debug) or pod2usage
(1);
36 pod2usage
(1) if($help || scalar(@ARGV) != 1);
38 my $file = abs_path
($ARGV[0]);
40 my $tmpdir = init_tmpdir
();
42 my $ksplice = unpack_update
($file);
45 foreach my $helper (glob('*-helper.ko')) {
47 (my $primary = $helper) =~ s/\-helper.ko$/.ko/;
48 die unless(-e
$primary && -e
$helper);
50 if(runval_raw
("insmod $primary debug=$debug") != 0) {
53 if(runval_raw
("insmod $helper debug=$debug") != 0) {
54 runval_raw
("rmmod $primary");
55 my $dmesg = runstr
("dmesg | grep ksplice");
56 while($dmesg =~ /ksplice_h: Preparing and checking/) {
60 my $bugreport = 'PACKAGE_BUGREPORT
';
61 if($dmesg =~ /could not match some sections/) {
64 Ksplice has aborted the upgrade because Ksplice has been unable to match the
65 object code produced by your current compiler and assembler against the running
66 kernel's object code
. If you provided the exact kernel source to the running
67 kernel
, then it appears that your current compiler
and/or assembler are
68 behaving differently from the compiler
and assembler used to build the running
69 kernel
. If possible
, please
use the exact compiler
and assembler that were
70 used to build the running kernel
. If you are using exactly the same compiler
71 and assembler
, feel free to report a bug to
$bugreport.
75 if($dmesg =~ /to-be-replaced code is busy/) {
78 Ksplice has aborted the upgrade because it appears that the code that you are
79 trying to patch is continuously in use by the system. More specifically,
80 Ksplice has been unable to find a moment when one or more of the to-be-patched
81 functions is not on a thread's kernel stack.
85 if($dmesg =~ /System[.]map does not match kernel/) {
88 Ksplice has aborted the upgrade because it appears that the System.map file
89 provided to ksplice-create does not match the running kernel.
96 if(runval_raw
("rmmod $helper") != 0) {
102 runval
("rm -rf $tmpdir");
108 ksplice-apply - Apply an on-disk Ksplice update to the running kernel
112 B<ksplice-apply> I<UPDATE_TARBALL>
116 B<ksplice-apply> takes as input a Ksplice update tarball, as generated by
117 L<ksplice-create(8)>, and it applies the update to the running binary kernel.
119 Specifically, B<ksplice-apply> does the following:
125 Inserts the "primary" module into the kernel.
129 Inserts the "helper" module into the kernel (doing so applies the
134 Removes the "helper" module from the kernel (that module is not needed
135 after the update has been applied).
139 The update tarball used with B<ksplice-apply> must have been generated for the
140 running kernel's version.
146 =item B<--debug=>I<DEBUG_LEVEL>
148 Applies the update with debugging output enabled. Recommended only for
149 debugging. I<DEBUG_LEVEL> should be an integer between 0 and 4. B<--debug=4>
150 provides the most debugging information.
160 Provides basic (pre-run matching and kernel stack check) debugging output.
164 Also provides full kernel stack check debugging output.
168 Also provides full pre-run matching debugging output.
172 Also provides full Ksplice relocation debugging output.
180 L<ksplice-create(8)>, L<ksplice-view(8)>, L<ksplice-undo(8)>
184 Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>.
186 This is free software and documentation. You can redistribute and/or modify it
187 under the terms of the GNU General Public License, version 2.