Skip to content

Commit

Permalink
Merge pull request #39 from imobach/add-memory-calibrator
Browse files Browse the repository at this point in the history
Support for high memory (bnc#882082)
  • Loading branch information
ancorgs committed Sep 18, 2015
2 parents 37c33be + db9a418 commit 6e95b94
Show file tree
Hide file tree
Showing 11 changed files with 923 additions and 320 deletions.
8 changes: 8 additions & 0 deletions package/yast2-kdump.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Sep 7 17:59:40 UTC 2015 - ancor@suse.com

- Added support for allocating low and high memory in systems
supporting the feature (bnc#882082)
- Fixed behavior during autoupgrade
- 3.1.26

-------------------------------------------------------------------
Tue Jul 21 15:34:11 UTC 2015 - igonzalezsosa@suse.com

Expand Down
7 changes: 5 additions & 2 deletions package/yast2-kdump.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-kdump
Version: 3.1.25
Version: 3.1.26
Release: 0
Summary: Configuration of kdump
License: GPL-2.0
Expand All @@ -37,7 +37,8 @@ BuildRequires: yast2-packager >= 2.17.24
BuildRequires: yast2-storage
BuildRequires: yast2-testsuite
Requires: yast2
Requires: yast2-bootloader >= 3.1.35
# Kernel parameters with multiple values and bug#945479 fixed
Requires: yast2-bootloader >= 3.1.148
Requires: yast2-ruby-bindings >= 1.0.0
Requires: yast2-storage
# SpaceCalculation.GetPartitionInfo
Expand Down Expand Up @@ -69,6 +70,8 @@ rake install DESTDIR="%{buildroot}"
%defattr(-,root,root)
%dir %{yast_yncludedir}/kdump
%{yast_yncludedir}/kdump/*
%dir %{yast_libdir}/kdump
%{yast_libdir}/kdump/*
%{yast_clientdir}/kdump.rb
%{yast_clientdir}/kdump_*.rb
%{yast_moduledir}/Kdump.*
Expand Down
7 changes: 5 additions & 2 deletions src/clients/kdump.rb
Expand Up @@ -740,14 +740,17 @@ def cmdKdumpStartup(options)
if Ops.get(options, "enable") != nil &&
Ops.get(options, "alloc_mem") != nil
Kdump.add_crashkernel_param = true
Kdump.allocated_memory = Builtins.tostring(Ops.get(options, "alloc_mem"))
Kdump.allocated_memory = { low: options["alloc_mem"].to_s }
#TRANSLATORS: CommandLine printed text
if Kdump.crashkernel_list_ranges
CommandLine.Print(
_(
"Kernel option \"crashkernel\" includes ranges. They will be rewritten."
"Kernel option \"crashkernel\" includes ranges and/or redundant values.\n"\
"It will be rewritten."
)
)
# Force value to false, so it's actually rewritten
Kdump.crashkernel_list_ranges = false
end
CommandLine.Print(_("To apply changes a reboot is necessary."))
return true
Expand Down
93 changes: 63 additions & 30 deletions src/include/kdump/dialogs.rb
Expand Up @@ -39,6 +39,10 @@ def initialize_kdump_dialogs(include_target)

Yast.include include_target, "kdump/helps.rb"
Yast.include include_target, "kdump/uifunctions.rb"
end

def wid_handling
return @wid_handling if @wid_handling

@wid_handling = {
"DisBackButton" => {
Expand Down Expand Up @@ -72,34 +76,7 @@ def initialize_kdump_dialogs(include_target)
},
"KdumpMemory" => {
"widget" => :custom,
"custom_widget" => HSquash(
VBox(
Left(
HBox(
Left(Label(_("Total System Memory [MB]:"))),
Left(Label(Id("total_memory"), "0123456789")),
HStretch()
)
),
Left(
HBox(
Left(Label(_("Usable Memory [MB]:"))),
Left(Label(Id("usable_memory"), "0123456789")),
HStretch()
)
),
Left(
IntField(
Id("allocated_memory"),
Opt(:notify),
_("Kdump Memor&y [MB]"),
32,
1048576,
128
)
)
)
),
"custom_widget" => HSquash(kdump_memory_widget),
"init" => fun_ref(
method(:InitKdumpMemory),
"void (string)"
Expand Down Expand Up @@ -416,6 +393,10 @@ def initialize_kdump_dialogs(include_target)
"help" => HelpKdump("NumberDumps")
}
}
end

def tabs
return @tabs if @tabs

@tabs = {
"start_up" => {
Expand Down Expand Up @@ -541,6 +522,58 @@ def initialize_kdump_dialogs(include_target)
}
end

def kdump_memory_widget
min = Kdump.memory_limits[:min_low].to_i
max = Kdump.memory_limits[:max_low].to_i
if Kdump.high_memory_supported?
low_label = _("Kdump &Low Memory [MiB]")
else
low_label = _("Kdump Memor&y [MiB]")
end
low_label += " (#{min} - #{max})"
widgets = [
Left(
HBox(
Left(Label(_("Total System Memory [MiB]:"))),
Left(Label(Id("total_memory"), "0123456789")),
HStretch()
)
),
Left(
HBox(
Left(Label(_("Usable Memory [MiB]:"))),
Left(Label(Id("usable_memory"), "0123456789")),
HStretch()
)
),
Left(
IntField(
Id("allocated_low_memory"),
Opt(:notify),
low_label,
min,
max,
0
)
)
]
if Kdump.high_memory_supported?
min = Kdump.memory_limits[:min_high].to_i
max = Kdump.memory_limits[:max_high].to_i
widgets << Left(
IntField(
Id("allocated_high_memory"),
Opt(:notify),
_("Kdump &High Memory [MiB]") + " (#{min} - #{max})",
min,
max,
0
)
)
end
VBox(*widgets)
end

def DisBackButton(key)
Wizard.SetTitleIcon("yast-kdump")
UI.ChangeWidget(Id(:back), :Enabled, false)
Expand All @@ -563,8 +596,8 @@ def RunKdumpDialogs
#return CWMTab::CreateWidget($[
"ids_order" => sim_dialogs,
"initial_screen" => "start_up",
"screens" => @tabs,
"widget_descr" => @wid_handling,
"screens" => tabs,
"widget_descr" => wid_handling,
"back_button" => "",
"abort_button" => Label.CancelButton,
"next_button" => Label.OKButton
Expand Down
93 changes: 54 additions & 39 deletions src/include/kdump/uifunctions.rb
Expand Up @@ -1363,64 +1363,75 @@ def HandleDumpLevel(key, event)
nil
end

# Function initializes option
# "KdumpMemory"
# Value of the low memory in UI
# @return [Integer]
def allocated_low_memory
UI.QueryWidget(Id("allocated_low_memory"), :Value).to_i
end

# Value of the high memory in UI, 0 if not supported
# @return [Integer]
def allocated_high_memory
if Kdump.high_memory_supported?
UI.QueryWidget(Id("allocated_high_memory"), :Value).to_i
else
0
end
end

# Total allocated memory, according to UI
# @return [Integer]
def allocated_memory
allocated_low_memory + allocated_high_memory
end

# Updates the free memory displayed in the UI
def update_usable_memory
value = Kdump.total_memory - allocated_memory
UI.ChangeWidget(Id("usable_memory"), :Value, value.to_s)
end

# Function initializes option
# "KdumpMemory"
def InitKdumpMemory(key)
if Ops.greater_than(Kdump.total_memory, 0)
if Kdump.total_memory > 0
UI.ChangeWidget(
Id("total_memory"),
:Value,
Builtins.tostring(Kdump.total_memory)
)
UI.ChangeWidget(
Id("allocated_memory"),
Id("allocated_low_memory"),
:Value,
Builtins.tointeger(Kdump.allocated_memory)
Builtins.tointeger(Kdump.allocated_memory[:low])
)
UI.ChangeWidget(
Id("usable_memory"),
:Value,
Builtins.tostring(
Ops.subtract(
Kdump.total_memory,
Convert.to_integer(UI.QueryWidget(Id("allocated_memory"), :Value))
)
if Kdump.high_memory_supported?
UI.ChangeWidget(
Id("allocated_high_memory"),
:Value,
Builtins.tointeger(Kdump.allocated_memory[:high])
)
)
end
update_usable_memory
else
UI.ChangeWidget(Id("total_memory"), :Value, "0")
UI.ChangeWidget(Id("usable_memory"), :Value, "0")
UI.ChangeWidget(Id("allocated_memory"), :Enabled, false)
UI.ChangeWidget(Id("allocated_low_memory"), :Enabled, false)
if Kdump.high_memory_supported?
UI.ChangeWidget(Id("allocated_high_memory"), :Enabled, false)
end
end

nil
end

# Hadle function for option
# Handle function for option
# "KdumpMemory"

def HandleKdumpMemory(key, event)
event = deep_copy(event)
ret = Ops.get(event, "ID")
if ret == "allocated_memory"
value = Convert.to_integer(UI.QueryWidget(Id("allocated_memory"), :Value))
if Ops.greater_than(value, Kdump.total_memory)
UI.ChangeWidget(Id("allocated_memory"), :Value, Kdump.total_memory)
UI.ChangeWidget(Id("usable_memory"), :Value, "0")
else
UI.ChangeWidget(
Id("usable_memory"),
:Value,
Builtins.tostring(
Ops.subtract(
Kdump.total_memory,
Convert.to_integer(UI.QueryWidget(Id("allocated_memory"), :Value))
)
)
)
end
if ["allocated_low_memory", "allocated_high_memory"].include?(ret)
update_usable_memory
end

nil
Expand All @@ -1431,25 +1442,29 @@ def HandleKdumpMemory(key, event)
# several ranges and ask user about rewritting
#
#"KdumpMemory"

def ValidKdumpMemory(key, event)
event = deep_copy(event)
if Kdump.crashkernel_list_ranges && Mode.normal
Kdump.crashkernel_list_ranges = !Popup.YesNo(
_("Kernel option includes several ranges. Rewrite it?")
_("Kernel option includes several ranges or redundant values. Rewrite it?")
)
end

true
end

# Store function for option
# "KdumpMemory"

def StoreKdumpMemory(key, event)
event = deep_copy(event)
Kdump.allocated_memory = Builtins.tostring(
UI.QueryWidget(Id("allocated_memory"), :Value)
Kdump.allocated_memory[:low] = Builtins.tostring(
UI.QueryWidget(Id("allocated_low_memory"), :Value)
)
if Kdump.high_memory_supported?
Kdump.allocated_memory[:high] = Builtins.tostring(
UI.QueryWidget(Id("allocated_high_memory"), :Value)
)
end

nil
end
Expand Down

0 comments on commit 6e95b94

Please sign in to comment.