Class: Yast::KernelClass
- Inherits:
-
Module
- Object
- Module
- Yast::KernelClass
- Includes:
- Logger
- Defined in:
- library/system/src/modules/Kernel.rb
Constant Summary collapse
- MODULES_CONF_FILE =
default configuration file for Kernel modules loaded on boot
"yast.conf".freeze
- MODULES_DIR =
directory where configuration for Kernel modules loaded on boot is stored
"/etc/modules-load.d/".freeze
- MODULES_SCR =
SCR path for reading/writing Kernel modules
Path.new(".kernel_modules_to_load")
- PAE_LIMIT =
specifies limit of memory which can be addressed without pae on 32-bit system
3_221_225_472
Instance Method Summary collapse
-
#AddCmdLine(name, arg) ⇒ Object
AddCmdLine () add "name=args" to kernel boot parameters add just "name" if args = "".
-
#AddModuleToLoad(name) ⇒ Object
Add a kernel module to the list of modules to load after boot.
-
#ComputePackage ⇒ String
Compute kernel package.
-
#ComputePackages ⇒ Array
Compute kernel packages.
-
#ComputePackagesForBase(base, _check_avail) ⇒ Object
Compute kernel package for the specified base kernel package.
-
#GetBinary ⇒ String
Het the name of kernel binary under /boot.
-
#GetCmdLine ⇒ String
Get the kernel command line.
- #GetFinalKernel ⇒ Object
-
#GetInformAboutKernelChange ⇒ Object
Get inform_about_kernel_change.
-
#GetPackages ⇒ Object
Get the list of kernel packages.
-
#GetVgaType ⇒ String
Get the vga= kernel parameter.
-
#HidePasswords(in_) ⇒ String
Hide passwords in command line option string.
-
#InformAboutKernelChange ⇒ Object
Display popup about new kernel that was installed.
-
#IsGraphicalDesktop ⇒ Object
Simple check any graphical desktop was selected.
- #main ⇒ Object
-
#module_to_be_loaded?(kernel_module) ⇒ Boolean
Returns whether the given kernel module is included in list of modules to be loaded on boot.
-
#modules_to_load ⇒ Hash
Returns hash of kernel modules to be loaded on boot - key is the config file - value is list of modules in that particular file.
-
#ParseInstallationKernelCmdline ⇒ void
Parse the installation-time kernel command line - the
vga
parameter is separated, see #GetVgaType - some specific parameters are ignored - the rest is passed on to @cmdLine for which #GetCmdLine is a reader. -
#ProbeKernel ⇒ void
select kernel depending on architecture and system type.
-
#propose_hibernation? ⇒ Boolean
gets if YaST should propose hibernation aka Kernel resume parameter.
-
#RemoveModuleToLoad(name) ⇒ Object
Remove a kernel module from the list of modules to load after boot.
-
#reset_modules_to_load ⇒ Object
Resets the internal cache.
-
#SaveModulesToLoad ⇒ Boolean
SaveModuleToLoad () save the sysconfig variable to /etc/modules-load.d/*.conf configuration files.
-
#SetInformAboutKernelChange(value) ⇒ Object
Set inform_about_kernel_change.
-
#SetPackages(custom_kernels) ⇒ Object
Set a custom kernel.
Instance Method Details
#AddCmdLine(name, arg) ⇒ Object
AddCmdLine () add "name=args" to kernel boot parameters add just "name" if args = ""
155 156 157 158 159 160 161 |
# File 'library/system/src/modules/Kernel.rb', line 155 def AddCmdLine(name, arg) ParseInstallationKernelCmdline() if !@cmdline_parsed @cmdLine = Ops.add(Ops.add(@cmdLine, " "), name) @cmdLine = Ops.add(Ops.add(@cmdLine, "="), arg) if arg != "" Builtins.y2milestone("cmdLine '%1'", HidePasswords(@cmdLine)) nil end |
#AddModuleToLoad(name) ⇒ Object
Add a kernel module to the list of modules to load after boot
484 485 486 487 488 |
# File 'library/system/src/modules/Kernel.rb', line 484 def AddModuleToLoad(name) Builtins.y2milestone("Adding module to be loaded at boot: %1", name) @modules_to_load[MODULES_CONF_FILE] << name unless module_to_be_loaded?(name) end |
#ComputePackage ⇒ String
Compute kernel package
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'library/system/src/modules/Kernel.rb', line 372 def ComputePackage packages = GetPackages() the_kernel = Ops.get(packages, 0, "") Builtins.y2milestone("Selecting '%1' as kernel package", the_kernel) # Check for provided kernel packages in installed system if Mode.normal || Mode.repair while the_kernel != "" && !Pkg.PkgInstalled(the_kernel) the_kernel = Ops.get(@fallbacks, the_kernel, "") Builtins.y2milestone("Not provided, falling back to '%1'", the_kernel) end else while the_kernel != "" && !Pkg.PkgAvailable(the_kernel) the_kernel = Ops.get(@fallbacks, the_kernel, "") Builtins.y2milestone( "Not available, falling back to '%1'", the_kernel ) end end if the_kernel == "" Builtins.y2warning( "%1 not available, using kernel-default", @kernel_packages ) @final_kernel = "kernel-default" else @final_kernel = the_kernel end @final_kernel end |
#ComputePackages ⇒ Array
Compute kernel packages
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'library/system/src/modules/Kernel.rb', line 427 def ComputePackages kernel = ComputePackage() ret = ComputePackagesForBase(kernel, true) if Ops.greater_than(Builtins.size(@kernel_packages), 1) # get the extra packages extra_pkgs = Builtins.remove(@kernel_packages, 0) # add available extra packages Builtins.foreach(extra_pkgs) do |pkg| if Pkg.IsAvailable(pkg) ret = Builtins.add(ret, pkg) Builtins.y2milestone("Added extra kernel package: %1", pkg) else Builtins.y2warning( "Extra kernel package '%1' is not available", pkg ) end end end Builtins.y2milestone("Computed kernel packages: %1", ret) deep_copy(ret) end |
#ComputePackagesForBase(base, _check_avail) ⇒ Object
Compute kernel package for the specified base kernel package
417 418 419 420 421 422 423 |
# File 'library/system/src/modules/Kernel.rb', line 417 def ComputePackagesForBase(base, _check_avail) # NOTE: kernel-*-nongpl packages have been dropped, use base only ret = [base] Builtins.y2milestone("Packages for base %1: %2", base, ret) deep_copy(ret) end |
#GetBinary ⇒ String
Het the name of kernel binary under /boot
358 359 360 361 |
# File 'library/system/src/modules/Kernel.rb', line 358 def GetBinary ProbeKernel() if !@kernel_probed @binary end |
#GetCmdLine ⇒ String
Get the kernel command line
206 207 208 209 |
# File 'library/system/src/modules/Kernel.rb', line 206 def GetCmdLine ParseInstallationKernelCmdline() if !@cmdline_parsed @cmdLine end |
#GetFinalKernel ⇒ Object
406 407 408 409 |
# File 'library/system/src/modules/Kernel.rb', line 406 def GetFinalKernel ComputePackage() if @final_kernel == "" @final_kernel end |
#GetInformAboutKernelChange ⇒ Object
Get inform_about_kernel_change.
547 548 549 |
# File 'library/system/src/modules/Kernel.rb', line 547 def GetInformAboutKernelChange @inform_about_kernel_change end |
#GetPackages ⇒ Object
Get the list of kernel packages
365 366 367 368 |
# File 'library/system/src/modules/Kernel.rb', line 365 def GetPackages ProbeKernel() if !@kernel_probed deep_copy(@kernel_packages) end |
#GetVgaType ⇒ String
Get the vga= kernel parameter
199 200 201 202 |
# File 'library/system/src/modules/Kernel.rb', line 199 def GetVgaType ParseInstallationKernelCmdline() if !@cmdline_parsed @vgaType end |
#HidePasswords(in_) ⇒ String
Hide passwords in command line option string
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'library/system/src/modules/Kernel.rb', line 120 def HidePasswords(in_) ret = "" if in_.nil? ret = nil else parts = Builtins.splitstring(in_, " ") first = true Builtins.foreach(parts) do |p| cmdopt = p if Builtins.regexpmatch(p, "^INST_PASSWORD=") cmdopt = "INST_PASSWORD=******" elsif Builtins.regexpmatch(p, "^FTPPASSWORD=") cmdopt = "FTPPASSWORD=********" end if first first = false else ret = Ops.add(ret, " ") end ret = Ops.add(ret, cmdopt) end end ret end |
#InformAboutKernelChange ⇒ Object
Display popup about new kernel that was installed
552 553 554 555 556 557 558 |
# File 'library/system/src/modules/Kernel.rb', line 552 def InformAboutKernelChange if GetInformAboutKernelChange() # inform the user that he/she has to reboot to activate new kernel Popup.Message(_("Reboot your system\nto activate the new kernel.\n")) end @inform_about_kernel_change end |
#IsGraphicalDesktop ⇒ Object
Simple check any graphical desktop was selected
212 213 214 215 216 217 |
# File 'library/system/src/modules/Kernel.rb', line 212 def IsGraphicalDesktop # Get patterns set for installation during desktop selection # (see DefaultDesktop::packages_proposal_ID_patterns for the first argument) pt = PackagesProposal.GetResolvables("DefaultDesktopPatterns", :pattern) Builtins.contains(pt, "x11") end |
#main ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'library/system/src/modules/Kernel.rb', line 50 def main Yast.import "Pkg" Yast.import "Arch" Yast.import "Mode" Yast.import "Linuxrc" Yast.import "PackagesProposal" Yast.import "Popup" Yast.import "Stage" Yast.import "FileUtils" Yast.import "ProductFeatures" textdomain "base" # kernel packages and binary @kernel_probed = false # the name of the kernel binary below '/boot'. @binary = "vmlinuz" # a list kernels to be installed. @kernel_packages = [] # the final kernel to be installed after verification and # availability checking @final_kernel = "" # kernel commandline @cmdline_parsed = false # string the kernel vga paramter @vgaType = "" # if "suse_update" given in cmdline @suse_update = false # string the kernel command line # Don't write it directly, @see: AddCmdLine() @cmdLine = "" # modules loaded on boot # Kernel modules configured to be loaded on boot @modules_to_load = nil @modules_to_load_old = nil # kernel was reinstalled # A flag to indicate if a popup informing about the kernel change should be displayed @inform_about_kernel_change = false # other variables # fallback map for kernel @fallbacks = { "kernel-pae" => "kernel-default", "kernel-desktop" => "kernel-default", # fallback for PPC (#302246) "kernel-iseries64" => "kernel-ppc64" } end |
#module_to_be_loaded?(kernel_module) ⇒ Boolean
Returns whether the given kernel module is included in list of modules to be loaded on boot
478 479 480 |
# File 'library/system/src/modules/Kernel.rb', line 478 def module_to_be_loaded?(kernel_module) modules_to_load.values.any? { |m| m.include?(kernel_module) } end |
#modules_to_load ⇒ Hash
Returns hash of kernel modules to be loaded on boot
- key is the config file
- value is list of modules in that particular file
467 468 469 470 471 |
# File 'library/system/src/modules/Kernel.rb', line 467 def modules_to_load read_modules_to_load if @modules_to_load.nil? @modules_to_load end |
#ParseInstallationKernelCmdline ⇒ void
This method returns an undefined value.
Parse the installation-time kernel command line
- the
vga
parameter is separated, see #GetVgaType - some specific parameters are ignored
- the rest is passed on to @cmdLine for which #GetCmdLine is a reader
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'library/system/src/modules/Kernel.rb', line 168 def ParseInstallationKernelCmdline @cmdline_parsed = true return if !(Stage.initial || Stage.cont) # Check if /etc/install.inf exists tmp = if !SCR.Dir(path(".etc.install_inf")).empty? SCR.Read(path(".etc.install_inf.Cmdline")).to_s # else check if there is agama specific filtered kernel options elsif ::File.exist?("/run/agama/cmdline.d/kernel.conf") WFM.Read(path(".local.string"), "/run/agama/cmdline.d/kernel.conf").to_s else # not using dedicated agent in order to use the same parser for cmdline # independently on whether it comes from /proc/cmdline or /etc/install.inf # use local read as it does not make sense to depend on binding it to chroot WFM.Read(path(".local.string"), "/proc/cmdline").to_s end Builtins.y2milestone( "cmdline from install.inf is: %1", HidePasswords(tmp) ) if !tmp.nil? # extract extra boot parameters given in installation ExtractCmdlineParameters(tmp) end nil end |
#ProbeKernel ⇒ void
This method returns an undefined value.
select kernel depending on architecture and system type.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'library/system/src/modules/Kernel.rb', line 226 def ProbeKernel kernel_desktop_exists = ((Mode.normal || Mode.repair) && Pkg.PkgInstalled("kernel-desktop")) || Pkg.PkgAvailable("kernel-desktop") Builtins.y2milestone( "Desktop kernel available: %1", kernel_desktop_exists ) @kernel_packages = ["kernel-default"] # add Xen paravirtualized drivers to a full virtualized host xen = Convert.to_boolean(SCR.Read(path(".probe.is_xen"))) if xen.nil? Builtins.y2warning("XEN detection failed, assuming XEN is NOT running") xen = false end Builtins.y2milestone("Detected XEN: %1", xen) if Arch.is_uml Builtins.y2milestone("ProbeKernel: UML") @kernel_packages = ["kernel-um"] elsif Arch.is_xen # kernel-xen contains PAE kernel (since oS11.0) @kernel_packages = ["kernel-xen"] elsif Arch.i386 # get flags from WFM /proc/cpuinfo (for pae and tsc tests below) cpuinfo_flags = Convert.to_string( SCR.Read(path(".proc.cpuinfo.value.\"0\".\"flags\"")) ) # check only first processor cpuflags = [] # bugzilla #303842 if cpuinfo_flags cpuflags = cpuinfo_flags.empty? ? [] : cpuinfo_flags.split else Builtins.y2error("Cannot read cpuflags") Builtins.y2milestone( "Mounted: %1", SCR.Execute(path(".target.bash_output"), "/usr/bin/mount -l") ) end # check for "roughly" >= 4GB memory (see bug #40729) memories = Convert.to_list(SCR.Read(path(".probe.memory"))) memsize = Ops.get_integer( memories, [0, "resource", "phys_mem", 0, "range"], 0 ) Builtins.y2milestone("Physical memory %1", memsize) # for memory > 4GB and PAE support we install kernel-pae, # PAE kernel is needed if NX flag exists as well (bnc#467328) if (Ops.greater_or_equal(memsize, PAE_LIMIT) || Builtins.contains(cpuflags, "nx")) && Builtins.contains(cpuflags, "pae") Builtins.y2milestone("Kernel switch: PAE detected") if kernel_desktop_exists && IsGraphicalDesktop() @kernel_packages = ["kernel-desktop"] # add PV drivers if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-desktop") @kernel_packages = Builtins.add( @kernel_packages, "xen-kmp-desktop" ) end else @kernel_packages = ["kernel-pae"] # add PV drivers if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-pae") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-pae") end end # add PV drivers elsif xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-default") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-default") end elsif Arch.x86_64 if kernel_desktop_exists && IsGraphicalDesktop() @kernel_packages = ["kernel-desktop"] if xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-desktop") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-desktop") end elsif xen Builtins.y2milestone("Adding Xen PV drivers: xen-kmp-default") @kernel_packages = Builtins.add(@kernel_packages, "xen-kmp-default") end elsif Arch.ppc @binary = "vmlinux" @kernel_packages = if Arch.board_iseries ["kernel-iseries64"] elsif Arch.ppc32 ["kernel-default"] else ["kernel-ppc64"] end elsif Arch.s390 @kernel_packages = ["kernel-default"] @binary = "image" end @kernel_probed = true Builtins.y2milestone("ProbeKernel determined: %1", @kernel_packages) nil end |
#propose_hibernation? ⇒ Boolean
gets if YaST should propose hibernation aka Kernel resume parameter
562 563 564 565 566 567 |
# File 'library/system/src/modules/Kernel.rb', line 562 def propose_hibernation? # Do not support s390. (jsc#SLE-6926) return false unless Arch.i386 || Arch.x86_64 true end |
#RemoveModuleToLoad(name) ⇒ Object
Remove a kernel module from the list of modules to load after boot
492 493 494 495 496 497 498 499 500 501 |
# File 'library/system/src/modules/Kernel.rb', line 492 def RemoveModuleToLoad(name) modules_to_load return true unless module_to_be_loaded?(name) Builtins.y2milestone("Removing module to be loaded at boot: %1", name) @modules_to_load.each do |_key, val| val.delete(name) end end |
#reset_modules_to_load ⇒ Object
Resets the internal cache
458 459 460 |
# File 'library/system/src/modules/Kernel.rb', line 458 def reset_modules_to_load @modules_to_load = nil end |
#SaveModulesToLoad ⇒ Boolean
SaveModuleToLoad () save the sysconfig variable to /etc/modules-load.d/*.conf configuration files
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'library/system/src/modules/Kernel.rb', line 506 def SaveModulesToLoad modules_to_load unless FileUtils.Exists(MODULES_DIR) log.warn "Directory #{MODULES_DIR} does not exist, creating" unless SCR::Execute(path(".target.mkdir"), MODULES_DIR) log.error "Cannot create directory #{MODULES_DIR}" return false end end success = true @modules_to_load.each do |file, modules| # The content hasn't changed next if modules.sort == @modules_to_load_old[file].sort if !register_modules_agent(file) Builtins.y2error("Cannot register new SCR agent for #{file_path} file") success = false next end SCR::Write(MODULES_SCR, modules) SCR.UnregisterAgent(MODULES_SCR) end success end |
#SetInformAboutKernelChange(value) ⇒ Object
Set inform_about_kernel_change.
540 541 542 543 544 |
# File 'library/system/src/modules/Kernel.rb', line 540 def SetInformAboutKernelChange(value) @inform_about_kernel_change = value nil end |
#SetPackages(custom_kernels) ⇒ Object
Set a custom kernel.
345 346 347 348 349 350 351 352 |
# File 'library/system/src/modules/Kernel.rb', line 345 def SetPackages(custom_kernels) custom_kernels = deep_copy(custom_kernels) # probe to avoid later probing ProbeKernel() if !@kernel_probed @kernel_packages = deep_copy(custom_kernels) nil end |