Skip to content

Commit 4bdb464

Browse files
committed
Created an anaconda addon to configure kdump
0 parents  commit 4bdb464

16 files changed

+1227
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
*.pyc

LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
This is an anaconda addon for configuring kdump. To use, copy the
2+
com_redhat_kdump directory into /usr/share/anaconda/addons on your
3+
installation media. /etc/kdump.conf will also be needed in the installation
4+
environment to provide the default contents of /etc/kdump.conf on the
5+
installed system.
6+
7+
The syntax of the addon's kickstart section is:
8+
9+
%addon com_redhat_kdump (--enable|--disable) --reserve-mb=("auto"|<amount>)
10+
<contents of /etc/kdump.conf>
11+
%end
12+
13+
Note that support for arguments on the %addon line was added in
14+
anaconda-21.22. See anaconda commit 3a512e4f9e15977f0ce2d0bbe39e841b881398f3,
15+
https://bugzilla.redhat.com/show_bug.cgi?id=1065674
16+

com_redhat_kdump/__init__.py

Whitespace-only changes.

com_redhat_kdump/common.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Kdump configuration common methods
2+
#
3+
# Copyright (C) 2014 Red Hat, Inc.
4+
#
5+
# This copyrighted material is made available to anyone wishing to use,
6+
# modify, copy, or redistribute it subject to the terms and conditions of
7+
# the GNU General Public License v.2, or (at your option) any later version.
8+
# This program is distributed in the hope that it will be useful, but WITHOUT
9+
# ANY WARRANTY expressed or implied, including the implied warranties of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11+
# Public License for more details. You should have received a copy of the
12+
# GNU General Public License along with this program; if not, write to the
13+
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
14+
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
15+
# source code or documentation are not subject to the GNU General Public
16+
# License and may only be used or replicated with the express permission of
17+
# Red Hat, Inc.
18+
#
19+
# Red Hat Author(s): David Shea <dshea@redhat.com>
20+
#
21+
22+
__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds"]
23+
24+
from pyanaconda.isys import total_memory
25+
from pyanaconda.flags import flags
26+
27+
_reservedMemory = None
28+
def getReservedMemory():
29+
"""Return the amount of memory currently reserved for kdump in MB."""
30+
global _reservedMemory
31+
32+
# Check if the value has already been read
33+
if _reservedMemory is not None:
34+
return _reservedMemory
35+
36+
try:
37+
with open("/sys/kernel/kexec_crash_size", "r") as fobj:
38+
_reservedMemory = int(fobj.read()) / (1024*1024)
39+
return _reservedMemory
40+
except (ValueError, IOError):
41+
return 0
42+
43+
def getTotalMemory():
44+
"""Return the total amount of system memory in MB
45+
46+
This is the amount reported by /proc/meminfo plus the aount
47+
currently reserved for kdump.
48+
"""
49+
50+
# total_memory return memory in KB, convert to MB
51+
availMem = total_memory() / 1024
52+
53+
return availMem + getReservedMemory()
54+
55+
def getMemoryBounds():
56+
"""Return a tuple of (lower, upper, step) for kdump reservation limits.
57+
58+
If there is not enough memory available to use kdump, both lower and
59+
upper will be 0.
60+
"""
61+
62+
totalMemory = getTotalMemory()
63+
64+
if flags.targetarch == 'ppc64':
65+
lowerBound = 256
66+
minUsable = 1024
67+
step = 1
68+
else:
69+
lowerBound = 128
70+
minUsable = 256
71+
step = 1
72+
73+
upperBound = (totalMemory - minUsable) - (totalMemory % step)
74+
75+
if upperBound < lowerBound:
76+
upperBound = lowerBound = 0
77+
78+
return (lowerBound, upperBound, step)

com_redhat_kdump/constants.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Kdump configuration constants
2+
#
3+
# Copyright (C) 2014 Red Hat, Inc.
4+
#
5+
# This copyrighted material is made available to anyone wishing to use,
6+
# modify, copy, or redistribute it subject to the terms and conditions of
7+
# the GNU General Public License v.2, or (at your option) any later version.
8+
# This program is distributed in the hope that it will be useful, but WITHOUT
9+
# ANY WARRANTY expressed or implied, including the implied warranties of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11+
# Public License for more details. You should have received a copy of the
12+
# GNU General Public License along with this program; if not, write to the
13+
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
14+
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
15+
# source code or documentation are not subject to the GNU General Public
16+
# License and may only be used or replicated with the express permission of
17+
# Red Hat, Inc.
18+
#
19+
# Red Hat Author(s): David Shea <dshea@redhat.com>
20+
#
21+
22+
# The location of the kdump config file
23+
CONFIG_FILE = "/etc/kdump.conf"

com_redhat_kdump/gui/__init__.py

Whitespace-only changes.

com_redhat_kdump/gui/spokes/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)