Skip to content

Commit

Permalink
Merge fc66f99 into 0125c67
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 9, 2022
2 parents 0125c67 + fc66f99 commit 321eff5
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 180 deletions.
10 changes: 10 additions & 0 deletions package/yast2-kdump.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Dec 9 09:53:31 UTC 2022 - Josef Reidinger <jreidinger@suse.com>

- Support fadump values in output of kdumptools calibrate
(jsc#PED-1927)
- drop support for older kdumptools
- remove limits when kdumptools calibrate failed to allow user
enter anything
- 4.5.7

-------------------------------------------------------------------
Wed Dec 7 17:14:38 UTC 2022 - Stefan Hundhammer <shundhammer@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-kdump.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-kdump
Version: 4.5.6
Version: 4.5.7
Release: 0
Summary: Configuration of kdump
License: GPL-2.0-only
Expand Down
25 changes: 15 additions & 10 deletions src/include/kdump/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def tabs
"widget_names" => [
"DisBackButton",
"EnableDisalbeKdump",
(Kdump.system.supports_fadump? ? "FADump" : ""),
(Kdump.fadump_supported? ? "FADump" : ""),
"KdumpMemory"
]
},
Expand Down Expand Up @@ -575,7 +575,8 @@ def kdump_memory_widget
)
),
VSpacing(1),
Left(ReplacePoint(Id("allocated_low_memory_rp"), low_memory_widget)),
Left(ReplacePoint(Id("allocated_low_memory_rp"),
low_memory_widget(fadump: Kdump.using_fadump?))),
*high_widgets
)
)
Expand Down Expand Up @@ -614,33 +615,37 @@ def RunKdumpDialogs

# Returns the low memory widget
#
# @param value [Integer] Current value
# @param value [Integer] Current value or default if nil passed
# @fadump fadump [Boolean] whener use low mem limits or fadump one
# @return [Yast::Term] Low memory widget
def low_memory_widget(value = nil)
def low_memory_widget(value: nil, fadump: false)
low_label = if Kdump.high_memory_supported?
_("Kdump &Low Memory [MiB]")
else
_("Kdump Memor&y [MiB]")
end

limits = Kdump.memory_limits
current = (limits[:min_low]..limits[:max_low]).cover?(value) ? value : limits[:default_low]
min_limit = fadump ? limits[:min_fadump] : limits[:min_low]
max_limit = fadump ? limits[:max_fadump] : limits[:max_low]
default = fadump ? limits[:default_fadump] : limits[:default_low]
current = (min_limit..max_limit).cover?(value) ? value : default

VBox(
IntField(
Id("allocated_low_memory"),
Opt(:notify),
low_label,
limits[:min_low],
limits[:max_low],
min_limit,
max_limit,
current
),
Label(
# TRANSLATORS: %{min}, %{max}, %{default} are variable names which must not be translated.
format(_("(min: %{min}; max: %{max}; suggested: %{default})"),
min: limits[:min_low],
max: limits[:max_low],
default: limits[:default_low])
min: min_limit,
max: max_limit,
default: default)
)
)
end
Expand Down
9 changes: 5 additions & 4 deletions src/include/kdump/uifunctions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ def StoreKdumpMemory(_key, _event)

# Initializes FADump settings in UI
def InitFADump(_key)
if Kdump.system.supports_fadump? && UI.WidgetExists(Id("FADump"))
if Kdump.fadump_supported? && UI.WidgetExists(Id("FADump"))
UI.ReplaceWidget(
Id("FADump"),
VBox(
Expand Down Expand Up @@ -1468,15 +1468,16 @@ def HandleFADump(_key, event)
UI.ChangeWidget(Id(:auto_resize), :Enabled, !use_fadump_value)

update_usable_memory
refresh_kdump_memory
refresh_kdump_memory(use_fadump_value)

nil
end

def refresh_kdump_memory
def refresh_kdump_memory(fadump)
widget_id = Id("allocated_low_memory")
value = UI.QueryWidget(widget_id, :Value)
UI.ReplaceWidget(Id("allocated_low_memory_rp"), low_memory_widget(value))
UI.ReplaceWidget(Id("allocated_low_memory_rp"),
low_memory_widget(value: value, fadump: fadump))
end

# Function initializes option
Expand Down
4 changes: 2 additions & 2 deletions src/lib/kdump/clients/kdump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def main
}
}

if Kdump.system.supports_fadump?
if Kdump.fadump_supported?
@cmdline_description["actions"]["fadump"] = {
"handler" => fun_ref(method(:cmd_handle_fadump), "boolean (map)"),
# TRANSLATORS: CommandLine help
Expand Down Expand Up @@ -718,7 +718,7 @@ def cmdKdumpShow(_options)

CommandLine.Print("")

if Kdump.system.supports_fadump?
if Kdump.fadump_supported?
show_fadump_status
CommandLine.Print("")
end
Expand Down
89 changes: 59 additions & 30 deletions src/lib/kdump/kdump_calibrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ module Yast
class KdumpCalibrator
include Yast::Logger

LOW_MEM = 896
MIN_LOW_DEFAULT = 72

KDUMPTOOL_CMD = "/usr/sbin/kdumptool %s calibrate".freeze
KDUMPTOOL_ARG = "--configfile '%s'".freeze
KEYS_MAP = {
"Low" => :default_low,
"MinLow" => :min_low,
"MaxLow" => :max_low,
"High" => :default_high,
"MinHigh" => :min_high,
"MaxHigh" => :max_high,
"Total" => :total_memory
"Low" => :default_low,
"MinLow" => :min_low,
"MaxLow" => :max_low,
"High" => :default_high,
"MinHigh" => :min_high,
"MaxHigh" => :max_high,
"Fadump" => :default_fadump,
"MinFadump" => :min_fadump,
"MaxFadump" => :max_fadump,
"Total" => :total_memory
}.freeze

def initialize(configfile = nil)
Expand All @@ -38,6 +38,13 @@ def high_memory_supported?
!max_high.zero?
end

# Determines whether fadump support is available
#
# @return [Boolean] true if it's available; 'false' otherwise.
def fadump_supported?
!max_fadump.zero?
end

# Determines what's the recommended quantity of low memory
#
# If high memory is not supported, this is the total recommended memory.
Expand All @@ -55,7 +62,7 @@ def default_low
# @return [Fixnum] Memory size (in MiB)
def min_low
run_kdumptool unless @kdumptool_executed
@min_low ||= MIN_LOW_DEFAULT
@min_low ||= 0
end

# Determines what's the recommended maximum quantity of low memory
Expand All @@ -65,7 +72,7 @@ def min_low
# @return [Fixnum] Memory size (in MiB)
def max_low
run_kdumptool unless @kdumptool_executed
@max_low ||= system.supports_high_mem? ? [LOW_MEM, total_memory].min : total_memory
@max_low ||= total_memory
end

# Determines what's the recommended quantity of high memory
Expand All @@ -84,19 +91,40 @@ def min_high
@min_high ||= 0
end

# Determines what's the recommended maximum quantity of low memory
# Determines what's the recommended maximum quantity of high memory
#
# If high memory is not supported, this is 0.
#
# @return [Fixnum] Memory size (in MiB)
def max_high
run_kdumptool unless @kdumptool_executed
@max_high ||=
if system.supports_high_mem?
(total_memory - LOW_MEM) > 0 ? total_memory - LOW_MEM : 0
else
0
end
@max_high ||= system.supports_high_mem? ? total_memory : 0
end

# Determines what's the recommended quantity of fadump memory
#
# @return [Fixnum] Memory size (in MiB)
def default_fadump
run_kdumptool unless @kdumptool_executed
@default_fadump ||= min_fadump
end

# Determines what's the minimum quantity of fadump memory
#
# @return [Fixnum] Memory size (in MiB)
def min_fadump
run_kdumptool unless @kdumptool_executed
@min_fadump ||= 0
end

# Determines what's the recommended maximum quantity of fadump memory
#
# If fadump is not supported, this is 0.
#
# @return [Fixnum] Memory size (in MiB)
def max_fadump
run_kdumptool unless @kdumptool_executed
@max_fadump ||= system.supports_fadump? ? total_memory : 0
end

# System available memory
Expand All @@ -115,8 +143,11 @@ def total_memory
#
# @return [Hash] Memory limits
def memory_limits
{ min_low: min_low, max_low: max_low, default_low: default_low,
min_high: min_high, max_high: max_high, default_high: default_high }
{
min_low: min_low, max_low: max_low, default_low: default_low,
min_high: min_high, max_high: max_high, default_high: default_high,
min_fadump: min_fadump, max_fadump: max_fadump, default_fadump: default_fadump
}
end

private
Expand All @@ -131,13 +162,16 @@ def system
def run_kdumptool
out = Yast::SCR.Execute(Yast::Path.new(".target.bash_output"), kdumptool_cmd)
if out["exit"].zero?
# ensure that fadump is set to unsupported as fadump can be missing in output
# and it means fadump not supported ( as oppose to high mem which is always in output)
@max_fadump = @min_fadump = @default_fadump = 0
proposal = parse(out["stdout"])
# Populate @min_low, @max_low, @total_memory, etc.
proposal.each_pair do |var_name, var_value|
instance_variable_set("@#{var_name}", var_value)
end
else
log.warn("kdumptool could not be executed: #{out["stderr"]}")
log.warn("kdumptool failed: #{out["stderr"]}")
end
@kdumptool_executed = true
end
Expand All @@ -149,14 +183,9 @@ def run_kdumptool
# @return [Hash] Hash containing minimum and maximum low/high memory limits
def parse(output)
lines = output.split("\n")
if lines.size == 1 # Old kdumptool version
low = lines.first.to_i
{ min_low: low, default_low: low }
else
lines.each_with_object({}) do |line, prop|
key, value = line.split(":").map(&:strip)
prop[KEYS_MAP[key]] = value.to_i if KEYS_MAP.key?(key)
end
lines.each_with_object({}) do |line, prop|
key, value = line.split(":").map(&:strip)
prop[KEYS_MAP[key]] = value.to_i if KEYS_MAP.key?(key)
end
end

Expand Down
24 changes: 13 additions & 11 deletions src/modules/Kdump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,10 @@ def calibrator
# jsc#SLE-21644 for more information.
#
# @return [Hash] The hash contains the following keys: :min_low, :max_low,
# :default_low, :min_high, :max_high, :default_high
# :default_low, :min_high, :max_high, :default_high, :min_fadump,
# :max_fadump, :default_fadump
def memory_limits
limits = calibrator.memory_limits
return limits unless using_fadump?

limits.merge(min_low: 0, max_low: total_memory)
calibrator.memory_limits
end

# Propose reserved/allocated memory
Expand Down Expand Up @@ -421,10 +419,7 @@ def update_initrd

return true unless using_fadump_changed?

# See FATE#315780
# See https://www.suse.com/support/kb/doc.php?id=7012786
# FIXME what about dracut?
update_command = (using_fadump? ? "/usr/sbin/mkdumprd -f" : "/sbin/mkinitrd")
update_command = "/usr/sbin/mkdumprd -f"
update_initrd_with(update_command)
end

Expand Down Expand Up @@ -1022,7 +1017,7 @@ def Import(settings)
# @return [Boolean] whether successfully set
def use_fadump(new_value)
# Trying to use fadump on unsupported hardware
if !system.supports_fadump? && new_value
if !fadump_supported? && new_value
Builtins.y2milestone("FADump is not supported on this hardware")
Report.Error(_("Cannot use Firmware-assisted dump.\nIt is not supported on this hardware."))
return false
Expand Down Expand Up @@ -1054,6 +1049,13 @@ def high_memory_supported?
calibrator.high_memory_supported?
end

# Returns whether usage of fadump is supported by the current system
#
# @return [Boolean] is supported
def fadump_supported?
calibrator.fadump_supported?
end

publish :function => :GetModified, :type => "boolean ()"
publish :function => :SetModified, :type => "void ()"
publish :variable => :modified, :type => "boolean"
Expand Down Expand Up @@ -1229,7 +1231,7 @@ def remove_offsets!(values)
end

def write_fadump_boot_param
if system.supports_fadump?
if fadump_supported?
# If fdump is selected and we want to enable kdump
value = "on" if using_fadump? && @add_crashkernel_param
Bootloader.modify_kernel_params(:common, :recovery, "fadump" => value)
Expand Down
6 changes: 3 additions & 3 deletions test/fadump_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe "#use_fadump" do
before do
allow(Yast::Kdump.system).to receive(:supports_fadump?).and_return(supported)
allow(Yast::Kdump).to receive(:fadump_supported?).and_return(supported)
end

context "if fadump is supported on this architecture" do
Expand Down Expand Up @@ -37,7 +37,7 @@

describe "#using_fadump?" do
it "returns that fadump is in use if previously set" do
allow(Yast::Kdump.system).to receive(:supports_fadump?).and_return(true)
allow(Yast::Kdump).to receive(:fadump_supported?).and_return(true)

Yast::Kdump.use_fadump(true)
expect(Yast::Kdump.using_fadump?).to eq(true)
Expand All @@ -55,7 +55,7 @@
end

it "returns true if use_fadump changed" do
allow(Yast::Kdump.system).to receive(:supports_fadump?).and_return(true)
allow(Yast::Kdump).to receive(:fadump_supported?).and_return(true)
Yast::Kdump.ReadKdumpSettings

original_value = Yast::Kdump.using_fadump?
Expand Down

0 comments on commit 321eff5

Please sign in to comment.