From 9578417eae9983d260a16f2f7229c7b0603fce28 Mon Sep 17 00:00:00 2001 From: lissav <lissav@us.ibm.com> Date: Mon, 18 Nov 2013 13:42:28 -0500 Subject: [PATCH 1/5] defect 3870 --- xCAT-server/lib/xcat/plugins/updatenode.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 425074fac..e23f5b31d 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -955,7 +955,7 @@ sub updatenode my $postscripts = "$installdir/postscripts"; if (-e $postscripts) { - my $cmd = "chmod -R u+x,a+r $postscripts"; + my $cmd = "chmod -R a+r $postscripts"; xCAT::Utils->runcmd($cmd, 0); my $rsp = {}; if ($::RUNCMD_RC != 0) From 004d179474b7832f52941332f0ef5b5d046f8699 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson <jbjohnso@us.ibm.com> Date: Mon, 18 Nov 2013 16:31:15 -0500 Subject: [PATCH 2/5] Fix SLES driver update media injection that is not rpm based --- xCAT-server/lib/xcat/plugins/sles.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 9e998e92c..510f5f683 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -2283,6 +2283,25 @@ sub insert_dd () { copy ("$dd_dir/initrd.gz", "$img"); } } elsif ($arch =~ /x86/) { + mkpath("$dd_dir/initrd_img/cus_driverdisk"); + + # insert the driver update disk into the cus_driverdisk dir + foreach my $dd (@dd_list) { + copy($dd, "$dd_dir/initrd_img/cus_driverdisk"); + } + # Repack the initrd + # In order to avoid the runcmd add the '2>&1' at end of the cpio + # cmd, the echo cmd is added at the end + $cmd = "cd $dd_dir/initrd_img; find . -print | cpio -H newc -o > $dd_dir/initrd | echo"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update disk failed. Could not pack the hacked initrd."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return (); + } + $cmd = "gzip -f $dd_dir/initrd"; + xCAT::Utils->runcmd($cmd, -1); my $rdhandle; my $ddhandle; open($rdhandle,">>",$img); From 089ea2da87e78e31bd838192452e4bba8c7b8537 Mon Sep 17 00:00:00 2001 From: ligc <liguangc@cn.ibm.com> Date: Tue, 19 Nov 2013 15:49:26 +0800 Subject: [PATCH 3/5] fix for bug 3913: do not use autocommit=0 for table read --- perl-xCAT/xCAT/DBobjUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 01683911a..5bf27c69e 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -618,7 +618,7 @@ sub getDBtable { # need to get info from DB - my $thistable = xCAT::Table->new($table, -create => 1, -autocommit => 0); + my $thistable = xCAT::Table->new($table, -create => 1); if (!$thistable) { return undef; From 2b615646840facf0d2a3b8a59c5fb03aab28d6d7 Mon Sep 17 00:00:00 2001 From: daniceexi <wxp@cn.ibm.com> Date: Tue, 19 Nov 2013 06:27:11 -0500 Subject: [PATCH 4/5] Code drop for new requirement: Add a new flag --ignorekernelchk for nodeset, geninitrd and genimage commands to skip the kernel version checking when injecting drivers from osimage.driverupdatesrc --- xCAT-client/bin/genimage | 6 ++ xCAT-server/lib/xcat/plugins/anaconda.pm | 97 +++++++++++++++++--- xCAT-server/lib/xcat/plugins/destiny.pm | 7 +- xCAT-server/lib/xcat/plugins/genimage.pm | 3 + xCAT-server/lib/xcat/plugins/geninitrd.pm | 23 +++-- xCAT-server/lib/xcat/plugins/sles.pm | 81 ++++++++++++---- xCAT-server/share/xcat/netboot/rh/genimage | 20 ++++ xCAT-server/share/xcat/netboot/sles/genimage | 20 ++++ 8 files changed, 218 insertions(+), 39 deletions(-) diff --git a/xCAT-client/bin/genimage b/xCAT-client/bin/genimage index a3c48af57..2f210d811 100755 --- a/xCAT-client/bin/genimage +++ b/xCAT-client/bin/genimage @@ -42,6 +42,7 @@ my $mode; my $interactive; my $onlyinitrd; my $dryrun; +my $ignorekernelchk; #----------------------------------------------------------------------------- =head3 print_usage - usage message @@ -88,6 +89,7 @@ if (!GetOptions( 'interactive' => \$interactive, 'onlyinitrd' => \$onlyinitrd, 'dryrun' => \$dryrun, + 'ignorekernelchk' => \$ignorekernelchk, 'h|help' => \$help, 'v|version' => \$version, )) { @@ -404,6 +406,10 @@ if ($dryrun) { push @arg, "--dryrun"; } +if ($ignorekernelchk) { + push @arg, "--ignorekernelchk"; +} + my $cmdref; push (@{$cmdref->{arg}}, @arg); $cmdref->{command}->[0] = "genimage"; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index adfe266d8..d8a1aae8d 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -175,6 +175,7 @@ sub mknetboot my @args = @{$req->{arg}} if(exists($req->{arg})); my @nodes = @{$req->{node}}; my $noupdateinitrd = $req->{'noupdateinitrd'}; + my $ignorekernelchk = $req->{'ignorekernelchk'}; my $ostab = xCAT::Table->new('nodetype'); #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; @@ -941,6 +942,7 @@ sub mkinstall my $doreq = shift; my @nodes = @{$request->{node}}; my $noupdateinitrd = $request->{'noupdateinitrd'}; + my $ignorekernelchk = $request->{'ignorekernelchk'}; #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; my $osimagetab; @@ -1353,7 +1355,7 @@ sub mkinstall unless ($noupdateinitrd) { copy($kernpath,"$tftppath"); copy($initrdpath,"$tftppath/initrd.img"); - &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", "$tftppath/vmlinuz", $driverupdatesrc, $netdrivers, $osupdir); + &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", "$tftppath/vmlinuz", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } } @@ -2429,6 +2431,7 @@ sub insert_dd { my $driverupdatesrc = shift; my $drivers = shift; my $osupdirlist = shift; + my $ignorekernelchk = shift; my $install_dir = xCAT::TableUtils->getInstallDir(); @@ -2439,6 +2442,7 @@ sub insert_dd { my @dd_list; my @rpm_list; + my @vendor_rpm; # the rpms from driverupdatesrc attribute my @driver_list; my $Injectalldriver; my $updatealldriver; @@ -2468,8 +2472,10 @@ sub insert_dd { push @dd_list, $1; } elsif ($src =~ /rpm:(.*)/i) { push @rpm_list, $1; + push @vendor_rpm, $1; } else { push @rpm_list, $src; + push @vendor_rpm, $src; } } } @@ -2498,6 +2504,7 @@ sub insert_dd { chomp(@dd_list); chomp(@rpm_list); + chomp(@vendor_rpm); unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); @@ -2606,24 +2613,48 @@ sub insert_dd { } } } - - # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver - # Change it back to xxx.ko here - $driver_name = "\*ko.new"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/*>); - foreach my $file (@all_real_path) { - my $newname = $file; - $newname =~ s/\.new$//; - $cmd = "/bin/mv -f $file $newname"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { + } + + # Extract files from vendor rpm when $ignorekernelchk is specified + if ($ignorekernelchk) { + mkpath "$dd_dir/vendor_rpm"; + foreach my $rpm (@vendor_rpm) { + if (-r $rpm) { + $cmd = "cd $dd_dir/vendor_rpm; rpm2cpio $rpm | cpio -idum"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not extract files from the rpm $rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $file."; + push @{$rsp->{data}}, "Handle the driver update failed. Could not read the rpm $rpm."; xCAT::MsgUtils->message("I", $rsp, $callback); } } } + + # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver + # Change it back to xxx.ko here + $driver_name = "\*ko.new"; + @all_real_path = (); + my @rpmfiles = <$dd_dir/rpm/*>; + if ($ignorekernelchk) { + push @rpmfiles, <$dd_dir/vendor_rpm/*>; + } + find(\&get_all_path, @rpmfiles); + foreach my $file (@all_real_path) { + my $newname = $file; + $newname =~ s/\.new$//; + $cmd = "/bin/mv -f $file $newname"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not move $file."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } } # The rh6 has different initrd format with old version (rh 5.x) @@ -2684,9 +2715,27 @@ sub insert_dd { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + if (@driver_list) { foreach my $driver (@driver_list) { $driver =~ s/\.gz$//; @@ -2903,9 +2952,27 @@ sub insert_dd { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + # create path for the new kernel in the modules package unless (-d "$dd_dir/modules/$kernelver") { mkpath ("$dd_dir/modules/$kernelver/$arch/"); @@ -3156,7 +3223,7 @@ sub insert_dd { if (@rpm_drivers) { push @{$rsp->{data}}, "The drivers:".join(',', sort(@rpm_drivers))." from ".join(',', sort(@rpm_list))." have been injected to initrd."; } elsif ($Injectalldriver) { - push @{$rsp->{data}}, "All the drivers from :".join(',', sort(@rpm_list))." have been injected to initrd."; + push @{$rsp->{data}}, "All the drivers from: ".join(',', sort(@rpm_list))." have been injected to initrd."; } else { push @{$rsp->{data}}, "No driver was injected to initrd."; } diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index a29818908..d4416a3e2 100644 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -93,7 +93,9 @@ sub setdestiny { @ARGV = @{$req->{arg}}; my $noupdateinitrd; - GetOptions('noupdateinitrd' => \$noupdateinitrd,); + my $ignorekernelchk; + GetOptions('noupdateinitrd' => \$noupdateinitrd, + 'ignorekernelchk' => \$ignorekernelchk,); my $state = $ARGV[0]; my $reststates; @@ -304,7 +306,8 @@ sub setdestiny { $errored=0; $subreq->({command=>["mk$tempstate"], node=>$samestatenodes, - noupdateinitrd=>$noupdateinitrd}, \&relay_response); + noupdateinitrd=>$noupdateinitrd, + ignorekernelchk=>$ignorekernelchk,}, \&relay_response); if ($errored) { $callback->({error=>"Some nodes failed to set up $state resources, aborting"}); return; diff --git a/xCAT-server/lib/xcat/plugins/genimage.pm b/xCAT-server/lib/xcat/plugins/genimage.pm index e2e3bb08a..d43ec2a05 100644 --- a/xCAT-server/lib/xcat/plugins/genimage.pm +++ b/xCAT-server/lib/xcat/plugins/genimage.pm @@ -69,6 +69,7 @@ sub process_request { my $onlyinitrd; my $tempfile; my $dryrun; + my $ignorekernelchk; GetOptions( 'a=s' => \$arch, @@ -88,6 +89,7 @@ sub process_request { 'onlyinitrd' => \$onlyinitrd, 'tempfile=s' => \$tempfile, 'dryrun' => \$dryrun, + 'ignorekernelchk' => \$ignorekernelchk, ); my $osimagetab; @@ -298,6 +300,7 @@ sub process_request { if (!$dryrun) { $cmd .= " --tempfile $tempfile"; } } if ($driverupdatesrc) { $cmd .= " --driverupdatesrc $driverupdatesrc"; } + if ($ignorekernelchk) { $cmd .= " --ignorekernelchk $ignorekernelchk"; } if($osfamily eq "sles") { my @entries = xCAT::TableUtils->get_site_attribute("timezone"); diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index 18782cb99..5e499ba25 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -28,15 +28,20 @@ sub preprocess_request my $usage = sub { my $callback = shift; - xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd <imagename> [-h | --help]"]}, $callback); + xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd <imagename> [--ignorekernelchk] [-h | --help]"]}, $callback); }; my $osimage; + my $ignorekernelchk; if (defined ($req->{arg})) { foreach (@{$req->{arg}}) { if (/^-/) { - $usage->($callback); - return; + if (/--ignorekernelchk/) { + $ignorekernelchk = 1; + } else { + $usage->($callback); + return; + } }else { $osimage = $_; } @@ -51,11 +56,13 @@ sub preprocess_request return; } + $req->{'ignorekernelchk'} = [$ignorekernelchk]; + #if tftpshared is not set, dispatch this command to all the service nodes my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp"); my $t_entry = $entries[0]; if ( defined($t_entry) and ($t_entry == 0 or $t_entry =~ /no/i)) { - $req->{'_disparatetftp'}=[1]; + $req->{'_disparatetftp'} = [1]; return xCAT::Scope->get_broadcast_scope($req,@_); } return [$req]; @@ -81,6 +88,10 @@ sub geninitrd { my $doreq = shift; my $osimage = $req->{arg}->[0]; + my $ignorekernelchk; + if (defined ($req->{'ignorekernelchk'}) && $req->{'ignorekernelchk'}->[0]) { + $ignorekernelchk = $req->{'ignorekernelchk'}->[0]; + } my ($osvers, $arch, $pkgdir, $driverupdatesrc, $netdrivers, $osdisupdir); @@ -218,10 +229,10 @@ sub geninitrd { # 2. Inject the drivers to initrd in /tftpboot base on the new kernel ver if ($osvers =~ /(^ol[0-9].*)|(centos.*)|(rh.*)|(fedora.*)|(SL.*)/) { require xCAT_plugin::anaconda; - xCAT_plugin::anaconda->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir); + xCAT_plugin::anaconda->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir, $ignorekernelchk); } elsif ($osvers =~ /(sles.*)|(suse.*)/) { require xCAT_plugin::sles; - xCAT_plugin::sles->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir); + xCAT_plugin::sles->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir, $ignorekernelchk); } } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 510f5f683..85570f62b 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -58,6 +58,7 @@ sub mknetboot my $nodes = @{$req->{node}}; my @nodes = @{$req->{node}}; my $noupdateinitrd = $req->{'noupdateinitrd'}; + my $ignorekernelchk = $req->{'ignorekernelchk'}; my $ostab = xCAT::Table->new('nodetype'); #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; @@ -711,6 +712,7 @@ sub mkinstall my $globaltftpdir = xCAT::TableUtils->getTftpDir(); my $noupdateinitrd = $request->{'noupdateinitrd'}; + my $ignorekernelchk = $request->{'ignorekernelchk'}; my @nodes = @{$request->{node}}; my $node; my $ostab = xCAT::Table->new('nodetype'); @@ -1039,20 +1041,20 @@ sub mkinstall unless ($noupdateinitrd) { copy("$pkgdir/1/boot/$arch/loader/linux", "$tftppath"); copy("$pkgdir/1/boot/$arch/loader/initrd", "$tftppath"); - @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } elsif ($arch =~ /x86/) { unless ($noupdateinitrd) { copy("$pkgdir/1/boot/i386/loader/linux", "$tftppath"); copy("$pkgdir/1/boot/i386/loader/initrd", "$tftppath"); - @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } elsif ($arch =~ /ppc/) { unless ($noupdateinitrd) { copy("$pkgdir/1/suseboot/inst64", "$tftppath"); - @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", undef, $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", undef, $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } } @@ -1949,6 +1951,7 @@ sub insert_dd () { my $driverupdatesrc = shift; my $drivers = shift; my $osupdirlist = shift; + my $ignorekernelchk = shift; my $install_dir = xCAT::TableUtils->getInstallDir(); @@ -1956,6 +1959,7 @@ sub insert_dd () { my @dd_list; my @rpm_list; + my @vendor_rpm; # the rpms from driverupdatesrc attribute my @driver_list; my $Injectalldriver; my $updatealldriver; @@ -1986,8 +1990,10 @@ sub insert_dd () { push @dd_list, $1; } elsif ($src =~ /rpm:(.*)/i) { push @rpm_list, $1; + push @vendor_rpm, $1; } else { push @rpm_list, $src; + push @vendor_rpm, $src; } } } @@ -2016,6 +2022,7 @@ sub insert_dd () { chomp(@dd_list); chomp(@rpm_list); + chomp(@vendor_rpm); unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); @@ -2087,26 +2094,50 @@ sub insert_dd () { xCAT::MsgUtils->message("I", $rsp, $callback); } } - } + } + } - # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver - # Change it back to xxx.ko here - $driver_name = "\*ko.new"; - @all_real_path = (); - find(\&get_all_path, <$dd_dir/rpm/*>); - foreach my $file (@all_real_path) { - my $newname = $file; - $newname =~ s/\.new$//; - $cmd = "mv -f $file $newname"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { + # Extract files from vendor rpm when $ignorekernelchk is specified + if ($ignorekernelchk) { + mkpath "$dd_dir/vendor_rpm"; + foreach my $rpm (@vendor_rpm) { + if (-r $rpm) { + $cmd = "cd $dd_dir/vendor_rpm; rpm2cpio $rpm | cpio -idum"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not extract files from the rpm $rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not rename $file."; + push @{$rsp->{data}}, "Handle the driver update failed. Could not read the rpm $rpm."; xCAT::MsgUtils->message("I", $rsp, $callback); } } } + # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver + # Change it back to xxx.ko here + $driver_name = "\*ko.new"; + @all_real_path = (); + my @rpmfiles = <$dd_dir/rpm/*>; + if ($ignorekernelchk) { + push @rpmfiles, <$dd_dir/vendor_rpm/*>; + } + find(\&get_all_path, @rpmfiles); + foreach my $file (@all_real_path) { + my $newname = $file; + $newname =~ s/\.new$//; + $cmd = "mv -f $file $newname"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not rename $file."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + # Copy the firmware to the rootimage if (-d "$dd_dir/rpm/lib/firmware") { if (! -d "$dd_dir/initrd_img/lib") { @@ -2166,9 +2197,27 @@ sub insert_dd () { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + if (@driver_list) { # copy the specific drivers to initrd foreach my $driver (@driver_list) { diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 5769d2983..9bcb7d30c 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -63,6 +63,7 @@ my $rootimg_dir; my $permission; # the permission works only for statelite mode currently my $tempfile; my $prompt; +my $ignorekernelchk; sub xdie { @@ -108,6 +109,7 @@ GetOptions( 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag 'interactive' =>\$prompt, 'onlyinitrd' =>\$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, ); if (@ARGV > 0) { @@ -1925,6 +1927,22 @@ sub load_dd () if (-d "$dd_dir/rpm/lib/firmware") { system ("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system ("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + # Copy the drivers to the rootimage if (-d "$dd_dir/rpm/lib/modules/$kernelver") { if (@driver_list) { @@ -1953,6 +1971,8 @@ sub load_dd () } } elsif ($Injectalldriver) { # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); my @all_drivers = @all_real_path; foreach my $new_driver (@all_drivers) { diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 3a87e43a8..f04aecaef 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -60,6 +60,7 @@ my $krpmver; my $tempfile; my $prompt; my $timezone; #the TIMEZONE of the stateless and statelite node +my $ignorekernelchk; sub xdie { system("rm -rf /tmp/xcatinitrd.$$"); @@ -106,6 +107,7 @@ GetOptions( 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag 'interactive' =>\$prompt, 'onlyinitrd' =>\$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, ); if (@ARGV > 0) { @@ -2003,6 +2005,22 @@ sub load_dd() if (-d "$dd_dir/rpm/lib/firmware") { system ("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system ("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + # Copy the drivers to the rootimage if (-d "$dd_dir/rpm/lib/modules/$kernelver") { #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; @@ -2032,6 +2050,8 @@ sub load_dd() } } elsif ($Injectalldriver) { # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); my @all_drivers = @all_real_path; foreach my $new_driver (@all_drivers) { From 5161d143bc416338bec738dd5d75da4be612d417 Mon Sep 17 00:00:00 2001 From: daniceexi <wxp@cn.ibm.com> Date: Tue, 19 Nov 2013 06:59:37 -0500 Subject: [PATCH 5/5] Change the man pages of nodeset,genimage and geninitrd commands for adding --ignorekernelchk option --- xCAT-client/pods/man1/genimage.1.pod | 5 ++++- xCAT-client/pods/man1/geninitrd.1.pod | 9 ++++++++- xCAT-client/pods/man8/nodeset.8.pod | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/xCAT-client/pods/man1/genimage.1.pod b/xCAT-client/pods/man1/genimage.1.pod index d297e6edd..11a46e2c8 100644 --- a/xCAT-client/pods/man1/genimage.1.pod +++ b/xCAT-client/pods/man1/genimage.1.pod @@ -8,7 +8,7 @@ B<genimage> B<genimage> B<-o> I<osver> [B<-a> I<arch>] B<-p> I<profile> B<-i> I<nodebootif> B<-n> I<nodenetdrivers> [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] -B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] I<imagename> +B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] [B<--ignorekernelchk>] I<imagename> B<genimage> [B<-h> | B<--help> | B<-v> | B<--version>] @@ -151,6 +151,9 @@ This flag shows the underlying call to the os specific genimage function. The us (Deprecated) This flag allows the user to setup the /tmp and the /var/tmp file system sizes. This flag is no longer supported. You can overwrite any file system size using the .postinstall script where you can create a new /etc/fstab file. +=item B<--ignorekernelchk> + +Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. =item B<-v|--version> diff --git a/xCAT-client/pods/man1/geninitrd.1.pod b/xCAT-client/pods/man1/geninitrd.1.pod index 65de247df..ef328b917 100644 --- a/xCAT-client/pods/man1/geninitrd.1.pod +++ b/xCAT-client/pods/man1/geninitrd.1.pod @@ -4,7 +4,7 @@ B<genimage> - Generate an initrd (initial ramfs) which to be used for statefull =head1 SYNOPSIS -B<geninitrd> <imagename> +B<geninitrd> I<imagename> [B<--ignorekernelchk>] B<geninitrd> [B<-h> | B<--help>] @@ -66,6 +66,13 @@ B<driverupdatesrc> - comma separated driver rpm packages (full path should be sp I<imagename> specifies the name of an os image definition to be used. The specification for the image is storted in the I<osimage> table and I<linuximage> table. +=over 12 + +=item B<--ignorekernelchk> + +Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + +=back =head1 RETURN VALUE diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index e0a2e6b74..997523f9d 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -6,7 +6,7 @@ B<nodeset> - set the boot state for a noderange B<nodeset> [I<noderange>] [I<boot>|I<install>|I<stat>|I<iscsiboot>|I<netboot>|I<statelite>|I<offline>|I<runcmd=bmcsetup>|I<osimage[=<imagename>>]] -B<nodeset> I<noderange> [I<osimage=<imagename>> I<--noupdateinitrd>] +B<nodeset> I<noderange> I<osimage=<imagename>> [I<--noupdateinitrd>] [I<--ignorekernelchk>] B<nodeset> [I<-h>|I<--help>|I<-v>|I<--version>] @@ -74,6 +74,10 @@ Prepare server for installing a node using the specified os image. The os image Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drviers to initrd. But, the geninitrd command should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of nodeset command. +=item B<--ignorekernelchk> + +Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + =item B<runimage>=<task>> If you would like to run a task after deployment, you can define that task with this attribute.