[PATCH] Add a anaconda addon to configurate kdump in the system installation process
by Arthur Zou
Currently this work is done by firstboot. Now we move to anaconda addon
to configurate in the system installation process.
Signed-off-by: Arthur Zou <zzou(a)redhat.com>
---
kdump-anaconda-addon-0.1/Makefile | 81 ++++++++
kdump-anaconda-addon-0.1/README | 30 +++
.../com_redhat_kdump/__init__.py | 0
.../com_redhat_kdump/common.py | 88 +++++++++
.../com_redhat_kdump/constants.py | 23 +++
.../com_redhat_kdump/gui/__init__.py | 0
.../com_redhat_kdump/gui/spokes/__init__.py | 0
.../com_redhat_kdump/gui/spokes/fedora.glade | 218 +++++++++++++++++++++
.../com_redhat_kdump/gui/spokes/kdump.py | 192 ++++++++++++++++++
kdump-anaconda-addon-0.1/com_redhat_kdump/i18n.py | 27 +++
.../com_redhat_kdump/ks/__init__.py | 0
.../com_redhat_kdump/ks/kdump.py | 128 ++++++++++++
.../com_redhat_kdump/tui/__init__.py | 0
.../com_redhat_kdump/tui/spokes/__init__.py | 0
.../com_redhat_kdump/tui/spokes/kdump.py | 87 ++++++++
kdump-anaconda-addon-0.1/po/Makefile | 75 +++++++
.../po/kdump-anaconda-addon.pot | 81 ++++++++
17 files changed, 1030 insertions(+)
create mode 100644 kdump-anaconda-addon-0.1/Makefile
create mode 100644 kdump-anaconda-addon-0.1/README
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/common.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/constants.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/gui/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/fedora.glade
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/kdump.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/i18n.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/ks/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/ks/kdump.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/tui/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/__init__.py
create mode 100644 kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/kdump.py
create mode 100644 kdump-anaconda-addon-0.1/po/Makefile
create mode 100644 kdump-anaconda-addon-0.1/po/kdump-anaconda-addon.pot
diff --git a/kdump-anaconda-addon-0.1/Makefile b/kdump-anaconda-addon-0.1/Makefile
new file mode 100644
index 0000000..7fd5ac4
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/Makefile
@@ -0,0 +1,81 @@
+NAME = kdump-anaconda-addon
+
+VERSION = 0.1
+
+ADDON = com_redhat_kdump
+TESTS = test
+
+FILES = $(ADDON) \
+ $(TESTS) \
+ po \
+ Makefile \
+ README
+
+EXCLUDES = \
+ *~ \
+ *.pyc
+
+all:
+ @echo "usage: make dist"
+ @echo " make test"
+ @echo " make install"
+ @echo " make uninstall"
+
+DISTNAME = $(NAME)-$(VERSION)
+ADDONDIR = /usr/share/anaconda/addons/
+DISTBALL = $(DISTNAME).tar.gz
+NUM_PROCS = $$(getconf _NPROCESSORS_ONLN)
+
+install:
+ mkdir -p $(DESTDIR)$(ADDONDIR)
+ cp -rv $(ADDON) $(DESTDIR)$(ADDONDIR)
+
+uninstall:
+ rm -rfv $(DESTDIR)$(ADDONDIR)
+
+dist:
+ rm -rf $(DISTNAME)
+ mkdir -p $(DISTNAME)
+ @if test -d ".git"; \
+ then \
+ echo Creating ChangeLog && \
+ ( cd "$(top_srcdir)" && \
+ echo '# Generate automatically. Do not edit.'; echo; \
+ git log --stat --date=short ) > ChangeLog.tmp \
+ && mv -f ChangeLog.tmp $(DISTNAME)/ChangeLog \
+ || ( rm -f ChangeLog.tmp ; \
+ echo Failed to generate ChangeLog >&2 ); \
+ else \
+ echo A git clone is required to generate a ChangeLog >&2; \
+ fi
+ for file in $(FILES); do \
+ cp -rpv $$file $(DISTNAME)/$$file; \
+ done
+ for excl in $(EXCLUDES); do \
+ find $(DISTNAME) -name "$$excl" -delete; \
+ done
+ tar -czvf $(DISTBALL) $(DISTNAME)
+ rm -rf $(DISTNAME)
+
+potfile:
+ $(MAKE) DESTDIR=$(DESTDIR) -C po potfile
+
+po-pull:
+ tx pull -a --disable-overwrite
+
+install-po-files:
+ $(MAKE) -C po install
+
+test:
+ @echo "***Running pylint checks***"
+ @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null
+ @echo "[ OK ]"
+ @echo "***Running unittests checks***"
+ @PYTHONPATH=. nosetests --processes=-1 -vw tests/
+
+runpylint:
+ @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null
+ @echo "[ OK ]"
+
+unittest:
+ PYTHONPATH=. nosetests --processes=-1 -vw tests/
diff --git a/kdump-anaconda-addon-0.1/README b/kdump-anaconda-addon-0.1/README
new file mode 100644
index 0000000..64d846e
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/README
@@ -0,0 +1,30 @@
+This is an anaconda addon for configuring kdump. To use, copy the
+com_redhat_kdump directory into /usr/share/anaconda/addons on your
+installation media.
+
+The syntax of the addon's kickstart section is:
+
+%addon com_redhat_kdump (--enable|--disable) --reserve-mb=("auto"|<amount>)
+<contents of /etc/kdump.conf>
+%end
+
+Note that support for arguments on the %addon line was added in
+anaconda-21.23. See anaconda commit 3a512e4f9e15977f0ce2d0bbe39e841b881398f3,
+https://bugzilla.redhat.com/show_bug.cgi?id=1065674
+
+How to test the kdump-anaconda-addon?
+You can provide an updates image in the kernel boot arguments as updates=,
+and the contents will be added to the stage2 filesystem.
+https://fedoraproject.org/wiki/Anaconda/Updates has more details, but usually
+the easiest is to make it available via HTTP or FTP and provide a url to updates=.
+
+The file is a gzip-compressed cpio archive, and the files need to be put into
+stage2 in /usr/share/anaconda/addons, so something like this will work to create
+an updates.img:
+
+mkdir -p updates/usr/share/anaconda/addons
+cp -r com_redhat_kdump updates/usr/share/anaconda/addons/
+( cd updates; find . | cpio -oc | gzip -c9 ) > updates.img
+
+then you can upload the updates.img to some http or ftp server so the anaconda
+can get it by boot parameter as updates=http://some.website.com/path/to/updates.img.
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/common.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/common.py
new file mode 100644
index 0000000..cd37131
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/common.py
@@ -0,0 +1,88 @@
+# Kdump configuration common methods
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+import os
+__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds", "getOS"]
+
+from pyanaconda.isys import total_memory
+from pyanaconda.flags import flags
+from com_redhat_kdump.constants import OS_RELEASE
+
+_reservedMemory = None
+def getReservedMemory():
+ """Return the amount of memory currently reserved for kdump in MB."""
+ global _reservedMemory
+
+ # Check if the value has already been read
+ if _reservedMemory is not None:
+ return _reservedMemory
+
+ try:
+ with open("/sys/kernel/kexec_crash_size", "r") as fobj:
+ _reservedMemory = int(fobj.read()) / (1024*1024)
+ return _reservedMemory
+ except (ValueError, IOError):
+ return 0
+
+def getTotalMemory():
+ """Return the total amount of system memory in MB
+
+ This is the amount reported by /proc/meminfo plus the aount
+ currently reserved for kdump.
+ """
+
+ # total_memory return memory in KB, convert to MB
+ availMem = total_memory() / 1024
+
+ return availMem + getReservedMemory()
+
+def getMemoryBounds():
+ """Return a tuple of (lower, upper, step) for kdump reservation limits.
+
+ If there is not enough memory available to use kdump, both lower and
+ upper will be 0.
+ """
+
+ totalMemory = getTotalMemory()
+
+ if flags.targetarch == 'ppc64':
+ lowerBound = 256
+ minUsable = 1024
+ step = 1
+ else:
+ lowerBound = 128
+ minUsable = 256
+ step = 1
+
+ upperBound = (totalMemory - minUsable) - (totalMemory % step)
+
+ if upperBound < lowerBound:
+ upperBound = lowerBound = 0
+
+ return (lowerBound, upperBound, step)
+
+def getOS():
+ with open(os.path.normpath(OS_RELEASE), "r") as fobj:
+ line = fobj.readline()
+
+ if not "Fedora" in line:
+ return "redhat"
+ else:
+ return "fedora"
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/constants.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/constants.py
new file mode 100644
index 0000000..aab9537
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/constants.py
@@ -0,0 +1,23 @@
+# Kdump configuration constants
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+# The location of the kdump config file
+OS_RELEASE = "/etc/os-release"
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/fedora.glade b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/fedora.glade
new file mode 100644
index 0000000..55442a8
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/fedora.glade
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface domain="kdump-anaconda-addon">
+ <requires lib="gtk+" version="3.6"/>
+ <!-- interface-requires AnacondaWidgets 1.0 -->
+ <object class="AnacondaSpokeWindow" id="KdumpWindow">
+ <property name="startup_id">filler</property>
+ <property name="can_focus">False</property>
+ <property name="startup_id">filler</property>
+ <property name="window_name" translatable="yes">KDUMP</property>
+ <signal name="button-clicked" handler="on_back_clicked" swapped="no"/>
+ <child internal-child="main_box">
+ <object class="GtkBox" id="AnacondaSpokeWindow-main_box1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child internal-child="nav_box">
+ <object class="GtkEventBox" id="AnacondaSpokeWindow-nav_box1">
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="nav_area">
+ <object class="GtkGrid" id="AnacondaSpokeWindow-nav_area1">
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="alignment">
+ <object class="GtkAlignment" id="AnacondaSpokeWindow-alignment1">
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <child internal-child="action_area">
+ <object class="GtkBox" id="AnacondaSpokeWindow-action_area1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="summaryLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Kdump is a kernel crash dumping mechanism. In the event of a system crash, kdump will capture information from your system that can be invaluable in determining the cause of the crash. Note that kdump does require reserving a portion of system memory that will be unavailable for other uses.</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="toBeReservedLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Memory To Be _Reserved (MB):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">toBeReservedSpin</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="toBeReservedSpin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">digits</property>
+ <property name="update_policy">if-valid</property>
+ <signal name="value-changed" handler="on_reserved_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Total System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Usable System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="enableKdumpCheck">
+ <property name="label" translatable="yes">_Enable kdump?</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_enable_kdump_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/kdump.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/kdump.py
new file mode 100644
index 0000000..cec6b06
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/gui/spokes/kdump.py
@@ -0,0 +1,192 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+"""Kdump anaconda GUI configuration"""
+
+from gi.repository import Gtk
+
+from pyanaconda.ui.gui.categories.system import SystemCategory
+from pyanaconda.ui.gui.spokes import NormalSpoke
+from pyanaconda.ui.gui.utils import fancy_set_sensitive
+
+from com_redhat_kdump.i18n import _, N_
+from com_redhat_kdump.common import getReservedMemory, getTotalMemory, getMemoryBounds, getOS
+
+__all__ = ["KdumpSpoke"]
+
+class KdumpSpoke(NormalSpoke):
+ """Kdump configuration spoke"""
+
+ builderObjects = ["KdumpWindow", "advancedConfigBuffer"]
+ mainWidgetName = "KdumpWindow"
+ uiFile = "RHEL.glade"
+ translationDomain = "kdump-anaconda-addon"
+
+ icon = "computer-fail-symbolic"
+ title = N_("KDUMP")
+ category = SystemCategory
+ OS = "redhat"
+ def __init__(self, data, storage, payload, instclass):
+ KdumpSpoke.OS = getOS()
+ if KdumpSpoke.OS == "fedora":
+ KdumpSpoke.uiFile = "fedora.glade"
+ NormalSpoke.__init__(self, data, storage, payload, instclass)
+ self._reserveMem = 0
+
+ def initialize(self):
+ NormalSpoke.initialize(self)
+ self._enableButton = self.builder.get_object("enableKdumpCheck")
+ KdumpSpoke.OS = getOS()
+ if KdumpSpoke.OS == "redhat":
+ self._reservationTypeLabel = self.builder.get_object("reservationTypeLabel")
+ self._autoButton = self.builder.get_object("autoButton")
+ self._manualButton = self.builder.get_object("manualButton")
+
+ self._toBeReservedLabel = self.builder.get_object("toBeReservedLabel")
+ self._toBeReservedSpin = self.builder.get_object("toBeReservedSpin")
+ self._totalMemLabel = self.builder.get_object("totalMemLabel")
+ self._totalMemMB = self.builder.get_object("totalMemMB")
+ self._usableMemLabel = self.builder.get_object("usableMemLabel")
+ self._usableMemMB = self.builder.get_object("usableMemMB")
+
+ # Set an initial value and adjustment on the spin button
+ lower, upper, step = getMemoryBounds()
+ adjustment = Gtk.Adjustment(lower, lower, upper, step, step, 0)
+ self._toBeReservedSpin.set_adjustment(adjustment)
+ self._toBeReservedSpin.set_value(lower)
+
+ def refresh(self):
+ # If a reserve amount is requested, set it in the spin button
+ if self.data.addons.com_redhat_kdump.reserveMB != "auto":
+ # Strip the trailing 'M'
+ reserveMB = self.data.addons.com_redhat_kdump.reserveMB
+ if reserveMB and reserveMB[-1] == 'M':
+ reserveMB = reserveMB[:-1]
+ if reserveMB:
+ self._toBeReservedSpin.set_value(int(reserveMB))
+
+ # Set the various labels. Use the spin button signal handler to set the
+ # usable memory label once the other two have been set.
+ self._totalMemMB.set_text("%d" % getTotalMemory())
+ self._toBeReservedSpin.emit("value-changed")
+
+ # Set the states on the toggle buttons and let the signal handlers set
+ # the sensitivities on the related widgets. Set the radio button first,
+ # since the radio buttons' bailiwick is a subset of that of the
+ # enable/disable checkbox.
+ if KdumpSpoke.OS == "redhat":
+ if self.data.addons.com_redhat_kdump.reserveMB == "auto":
+ self._autoButton.set_active(True)
+ self._manualButton.set_active(False)
+ else:
+ self._autoButton.set_active(False)
+ self._manualButton.set_active(True)
+
+ if self.data.addons.com_redhat_kdump.enabled:
+ self._enableButton.set_active(True)
+ else:
+ self._enableButton.set_active(False)
+
+ # Force a toggled signal on the button in case it's state has not changed
+ self._enableButton.emit("toggled")
+
+ def apply(self):
+ # Copy the GUI state into the AddonData object
+ self.data.addons.com_redhat_kdump.enabled = self._enableButton.get_active()
+
+ if KdumpSpoke.OS == "redhat" and self._autoButton.get_active():
+ reserveMem = "auto"
+ else:
+ reserveMem = "%dM" % self._toBeReservedSpin.get_value_as_int()
+
+ self.data.addons.com_redhat_kdump.reserveMB = reserveMem
+
+
+ @property
+ def ready(self):
+ return True
+
+ @property
+ def completed(self):
+ # Always treat as completed
+ return True
+
+ @property
+ def mandatory(self):
+ return False
+
+ @property
+ def status(self):
+ if self.data.addons.com_redhat_kdump.enabled:
+ state = _("Kdump is enabled")
+ else:
+ state = _("Kdump is disabled")
+
+ return state
+
+ # SIGNAL HANDLERS
+
+ def on_enable_kdump_toggled(self, checkbutton, user_data=None):
+ status = checkbutton.get_active()
+
+ # If disabling, set everything to insensitve. Otherwise, only set the radio
+ # button and currently reserved widgets to sensitive and then fake a
+ # toggle event on the radio button to set the state on the reserve
+ # amount spin button and total/usable mem display.
+ if KdumpSpoke.OS == "redhat":
+ self._autoButton.set_sensitive(status)
+ self._manualButton.set_sensitive(status)
+ self._reservationTypeLabel.set_sensitive(status)
+
+ if not status:
+ fancy_set_sensitive(self._toBeReservedSpin, status)
+ self._totalMemLabel.set_sensitive(status)
+ self._totalMemMB.set_sensitive(status)
+ self._usableMemLabel.set_sensitive(status)
+ self._usableMemMB.set_sensitive(status)
+ elif KdumpSpoke.OS == "redhat":
+ self._autoButton.emit("toggled")
+ else:
+ fancy_set_sensitive(self._toBeReservedSpin, True)
+ self._totalMemLabel.set_sensitive(True)
+ self._totalMemMB.set_sensitive(True)
+ self._usableMemLabel.set_sensitive(True)
+ self._usableMemMB.set_sensitive(True)
+
+ def on_reservation_toggled(self, radiobutton, user_data=None):
+ status = self._manualButton.get_active()
+
+ # If setting to auto, disable the manual config spinner and
+ # the total/usable memory labels
+ fancy_set_sensitive(self._toBeReservedSpin, status)
+ self._totalMemLabel.set_sensitive(status)
+ self._totalMemMB.set_sensitive(status)
+ self._usableMemLabel.set_sensitive(status)
+ self._usableMemMB.set_sensitive(status)
+
+ def on_reserved_value_changed(self, spinbutton, user_data=None):
+ reserveMem = spinbutton.get_value_as_int()
+ totalMemText = self._totalMemMB.get_text()
+
+ # If no total memory is available yet, do nothing
+ if totalMemText:
+ totalMem = int(self._totalMemMB.get_text())
+ self._usableMemMB.set_text("%d" % (totalMem - reserveMem))
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/i18n.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/i18n.py
new file mode 100644
index 0000000..a8cd27a
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/i18n.py
@@ -0,0 +1,27 @@
+# Kdump configuration translation functions
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+__all__ = ["_", "N_"]
+
+import gettext
+
+_ = lambda x: gettext.ldgettext("kdump-anaconda-addon", x)
+N_ = lambda x: x
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/ks/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/ks/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/ks/kdump.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/ks/kdump.py
new file mode 100644
index 0000000..b4b346c
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/ks/kdump.py
@@ -0,0 +1,128 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+import os
+
+from pyanaconda.addons import AddonData
+from pyanaconda.constants import ROOT_PATH
+from pyanaconda import iutil
+
+from pykickstart.options import KSOptionParser
+from pykickstart.errors import KickstartParseError, formatErrorMsg
+from com_redhat_kdump.common import getOS, getMemoryBounds
+from com_redhat_kdump.i18n import _
+
+__all__ = ["KdumpData"]
+
+class KdumpData(AddonData):
+ """Addon data for the kdump configuration"""
+
+ def __init__(self, name):
+ AddonData.__init__(self, name)
+
+ self.enabled = True
+ self.reserveMB = "auto"
+ if getOS() == "fedora":
+ self.enabled = False
+ lower, upper, step = getMemoryBounds()
+ self.reserveMB = "%d" % lower
+
+ def __str__(self):
+ addon_str = "%%addon %s" % self.name
+
+ if self.enabled:
+ addon_str += " --enable"
+ else:
+ addon_str += " --disable"
+
+ if self.reserveMB:
+ addon_str += " --reserve-mb='%s'" % self.reserveMB
+
+ addon_str += "\n%s\n%%end\n" % self.content.strip()
+
+ return addon_str
+
+ def setup(self, storage, ksdata, instClass):
+ # Clear any existing crashkernel bootloader arguments
+ if ksdata.bootloader.appendLine:
+ ksdata.bootloader.appendLine = ' '.join(
+ (arg for arg in ksdata.bootloader.appendLine.split() \
+ if not arg.startswith('crashkernel=')))
+
+ # Copy our reserved amount to the bootloader arguments
+ if self.enabled:
+ # Ensure that the amount is "auto" or an amount in MB
+ if self.reserveMB != "auto" and self.reserveMB[-1] != 'M':
+ self.reserveMB += 'M'
+ ksdata.bootloader.appendLine += ' crashkernel=%s' % self.reserveMB
+
+ # Do the same thing with the storage.bootloader.boot_args set
+ if storage.bootloader.boot_args:
+ crashargs = [arg for arg in storage.bootloader.boot_args \
+ if arg.startswith('crashkernel=')]
+ storage.bootloader.boot_args -= set(crashargs)
+
+ if self.enabled:
+ storage.bootloader.boot_args.add('crashkernel=%s' % self.reserveMB)
+ ksdata.packages.packageList.append("kexec-tools")
+
+ def handle_header(self, lineno, args):
+ op = KSOptionParser()
+ op.add_option("--enable", action="store_true", default=True,
+ dest="enabled", help="Enable kdump")
+ op.add_option("--disable", action="store_false",
+ dest="enabled", help="Disable kdump")
+ op.add_option("--reserve-mb", type="string", dest="reserveMB",
+ default="auto", help="Amount of memory in MB to reserve for kdump, or auto")
+
+ (opts, extra) = op.parse_args(args=args, lineno=lineno)
+
+ # Reject any additional arguments
+ if extra:
+ AddonData.handle_header(self, lineno, extra)
+
+ # Validate the reserve-mb argument
+ if opts.reserveMB != "auto":
+ # Allow a final 'M' for consistency with the crashkernel kernel
+ # parameter. Strip it if found.
+ if opts.reserveMB and opts.reserveMB[-1] == 'M':
+ opts.reserveMB = opts.reserveMB[:-1]
+
+ try:
+ _test = int(opts.reserveMB)
+ except ValueError:
+ msg = _("Invalid value %s for --reserve-mb") % opts.reserveMB
+ if lineno != None:
+ raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
+ else:
+ raise KickstartParseError(msg)
+
+ # Store the parsed arguments
+ self.enabled = opts.enabled
+ self.reserveMB =opts.reserveMB
+
+ def execute(self, storage, ksdata, instClass, users):
+ if self.enabled:
+ action = "enable"
+ else:
+ action = "disable"
+
+ iutil.execWithRedirect("systemctl", [action, "kdump.service"], root=ROOT_PATH)
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/__init__.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/kdump.py b/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/kdump.py
new file mode 100644
index 0000000..23e8040
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/com_redhat_kdump/tui/spokes/kdump.py
@@ -0,0 +1,87 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+"""Kdump anaconda TUI configuration"""
+
+import re
+
+from pyanaconda.ui.tui.spokes import EditTUISpoke
+from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
+from com_redhat_kdump.common import getOS, getMemoryBounds
+from com_redhat_kdump.i18n import N_, _
+
+__all__ = ["KdumpSpoke"]
+
+class _re:
+ def __init__(self, patten, low, up):
+ self.re = re.compile(patten)
+ self.low = low
+ self.up = up
+
+ def match(self, key):
+ if self.re.match(key):
+ if key == "auto":
+ return True
+ if key[-1] == 'M':
+ key = key[:-1]
+ key = int(key)
+ if key <= self.up and key >= self.low :
+ return True
+ return False
+
+lower, upper ,step = getMemoryBounds()
+# Allow either "auto" or a string of digits optionally followed by 'M'
+RESERVE_VALID = _re(r'^((auto)|(\d+M?))$', lower, upper)
+FEDORA_RESERVE_VALID = _re(r'^(\d+M?)$', lower, upper)
+
+class KdumpSpoke(EditTUISpoke):
+ title = N_("Kdump")
+ category = "system"
+
+ edit_fields = [
+ Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
+ Entry("Reserve amount", "reserveMB", RESERVE_VALID, lambda self,args: args.enabled)
+ ]
+
+ def __init__(self, app, data, storage, payload, instclass):
+ if getOS() == "fedora":
+ KdumpSpoke.edit_fields = [
+ Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
+ Entry("Reserve amount", "reserveMB", FEDORA_RESERVE_VALID, lambda self,args: args.enabled)
+ ]
+
+ EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
+ self.args = self.data.addons.com_redhat_kdump
+
+ def apply(self):
+ pass
+
+ @property
+ def completed(self):
+ return True
+
+ @property
+ def status(self):
+ if self.args.enabled:
+ state = _("Kdump is enabled")
+ else:
+ state = _("Kdump is disabled")
+ return state
diff --git a/kdump-anaconda-addon-0.1/po/Makefile b/kdump-anaconda-addon-0.1/po/Makefile
new file mode 100644
index 0000000..2fab84d
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/po/Makefile
@@ -0,0 +1,75 @@
+#
+# Makefile for the PO files (translation) catalog
+#
+# $Id$
+
+TOP = ../..
+
+# What is this package?
+NLSPACKAGE = kdump-anaconda-addon
+POTFILE = $(NLSPACKAGE).pot
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = $(INSTALL) -m 644
+INSTALL_DIR = /usr/bin/install -d
+
+# destination directory
+INSTALL_NLS_DIR = $(DESTDIR)/usr/share/locale
+# PO catalog handling
+MSGMERGE = msgmerge -v
+XGETTEXT = xgettext --default-domain=$(NLSPACKAGE) \
+ --add-comments
+MSGFMT = msgfmt --statistics --verbose
+
+# What do we need to do
+POFILES = $(wildcard ./kexec-tools-po/*.po)
+MOFILES = $(patsubst %.po,%.mo,$(POFILES))
+PYSRC = $(wildcard ../com_redhat_kdump/*.py ../com_redhat_kdump/*/*.py ../com_redhat_kdump/*/*/*.py)
+GLADEFILES = $(wildcard ../com_redhat_kdump/gui/spokes/*.glade)
+
+all:: update-po $(MOFILES)
+
+potfile: $(PYSRC) glade-po
+ $(XGETTEXT) -L Python --keyword=_ --keyword=N_ $(PYSRC) tmp/*.h
+ @if cmp -s $(NLSPACKAGE).po $(POTFILE); then \
+ rm -f $(NLSPACKAGE).po; \
+ else \
+ mv -f $(NLSPACKAGE).po $(POTFILE); \
+ fi; \
+ rm -rf tmp/
+
+glade-po: $(GLADEFILES)
+ rm -rf tmp/
+ for f in $(GLADEFILES); do \
+ intltool-extract --type=gettext/glade -l $$f ;\
+ done
+
+update-po: Makefile refresh-po
+
+refresh-po: Makefile
+ for cat in $(POFILES); do \
+ if $(MSGMERGE) $$cat $(POTFILE) --out=$$cat ; then \
+ echo "$(MSGMERGE) of $$cat succeeded" ; \
+ else \
+ echo "$(MSGMERGE) of $$cat failed" ; \
+ fi \
+ done
+
+clean:
+ @rm -fv *mo *~ .depend
+ @rm -rf tmp
+
+install: $(MOFILES)
+ @for n in $(MOFILES); do \
+ l=`basename $$n .mo`; \
+ $(INSTALL_DIR) $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \
+ $(INSTALL_DATA) --verbose $$n $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
+ done
+
+uninstall:
+ rm -rfv $(INSTALL_NLS_DIR)/*/LC_MESSAGES/$(NLSPACKAGE).mo
+
+%.mo: %.po
+ $(MSGFMT) -o $@ $<
+
+.PHONY: missing depend
+
diff --git a/kdump-anaconda-addon-0.1/po/kdump-anaconda-addon.pot b/kdump-anaconda-addon-0.1/po/kdump-anaconda-addon.pot
new file mode 100644
index 0000000..3b9b641
--- /dev/null
+++ b/kdump-anaconda-addon-0.1/po/kdump-anaconda-addon.pot
@@ -0,0 +1,81 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-09 15:07+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL(a)li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../com_redhat_kdump/ks/kdump.py:112
+#, python-format
+msgid "Invalid value %s for --reserve-mb"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:56
+msgid "Kdump"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:84
+#: ../com_redhat_kdump/gui/spokes/kdump.py:138
+msgid "Kdump is enabled"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:86
+#: ../com_redhat_kdump/gui/spokes/kdump.py:140
+msgid "Kdump is disabled"
+msgstr ""
+
+#: ../com_redhat_kdump/gui/spokes/kdump.py:43
+msgid "_KDUMP"
+msgstr ""
+
+#: tmp/fedora.glade.h:1 tmp/kdump.glade.h:1
+msgid "KDUMP"
+msgstr ""
+
+#: tmp/fedora.glade.h:2 tmp/kdump.glade.h:2
+msgid ""
+"Kdump is a kernel crash dumping mechanism. In the event of a system crash, "
+"kdump will capture information from your system that can be invaluable in "
+"determining the cause of the crash. Note that kdump does require reserving a "
+"portion of system memory that will be unavailable for other uses."
+msgstr ""
+
+#: tmp/fedora.glade.h:3 tmp/kdump.glade.h:7
+msgid "Memory To Be Reserved (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:4 tmp/kdump.glade.h:8
+msgid "Total System Memory (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:5 tmp/kdump.glade.h:9
+msgid "Usable System Memory (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:6 tmp/kdump.glade.h:3
+msgid "_Enable kdump?"
+msgstr ""
+
+#: tmp/kdump.glade.h:4
+msgid "Kdump Memory Reservation:"
+msgstr ""
+
+#: tmp/kdump.glade.h:5
+msgid "_Automatic"
+msgstr ""
+
+#: tmp/kdump.glade.h:6
+msgid "_Manual"
+msgstr ""
--
1.8.4.2
9 years, 11 months
Re: Mass bug: packages should not auto-enable systemd units
by Dave Young
On 04/30/14 at 09:02am, Andrew Lutomirski wrote:
> Due to some confusion around how alternatives worked, I screwed up the
> list of packages here. I've updated it below. I'll give it a few
> more days before filing the actual bugs.
>
> On Wed, Apr 23, 2014 at 4:59 PM, Andrew Lutomirski <luto(a)mit.edu> wrote:
> > Hi everyone-
> >
> > This is a notice in accordance with the mass bug filing procedure.
> >
> > A number of packages install systemd units and enable them
> > automatically. They should not. Please update these packages to use the
> > macroized scriptlet
> > (https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd).
> >
> > If your package has an exception from FESCo permitting it to enable
> > itself, please make sure that the service in question is listed in the
> > appropriate preset file.
> >
> > There is a general exception described here:
> >
> > https://fedoraproject.org/wiki/Starting_services_by_default
> >
> > If your package falls under the general exception, then it is possible
> > that no change is required. Nevertheless, if you are relying on the
> > exception, please make sure that your rpm scripts are sensible. The
> > exception is:
> >
> > In addition, any service which does not remain persistent on the
> > system (aka, it "runs once then goes away"), does not listen to
> > incoming connections during initialization, and does not require
> > configuration to be functional may be enabled by default (but is not
> > required to do so). An example of "runs once then goes away" service
> > is iptables.
> >
> > Given that this issue can affect Fedora 20 users who install your
> > package as a dependency, these bugs should be fixed in Fedora 20 and
> > Rawhide.
> >
> > The tracker bug is here:
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=1090684
> >
> > I created it early because three of the bugs are pre-existing. Next
> > week, I'll file bugs against the packages below. If you fix your
> > package in the mean time, please let me know.
> >
> > After three weeks, provenpackagers may step in and fix these issues.
> >
>
> abrt
> acpid
> aeolus-audrey-agent
> aeolus-configserver
> audit
> avahi
> bluez
> bootchart
> cherokee
> cloud-init
> deltacloud-core
> dmapd
> dnssec-trigger
> glusterfs
> gnome-initial-setup
> gpsd
> ipmiutil
> iptables
> kexec-tools
Cc kexec-tools list.
> libstoragemgmt
> libvirt
> lttng-tools
> monit
> NetworkManager
> nfs-utils
> nss-pam-ldapd
> olpc-kbdshim
> olpc-powerd
> openct
> pcsc-lite
> qemu
> qpid-cpp
> rootfs-resize
> rpcbind
> sendmail
> soundmodem
> spacenavd
> subscription-manager
> supervisor
> systemd
> targetcli
> util-linux
> vdsm
> xen
>
> --Andy
> _______________________________________________
> devel-announce mailing list
> devel-announce(a)lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/devel-announce
> --
> devel mailing list
> devel(a)lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/devel
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
9 years, 11 months
[PATCH] Disable the ratelimit of kdump service on hotplug events
by Prarit Bhargava
When doing cpu softplug via /sys
ie)
echo 0 > /sys/devices/system/cpu/cpuX/online
echo 1 > /sys/devices/system/cpu/cpuX/online
the kdump service is restarted on every cpu up and down. Eventually the
service stops because it is rate limited by systemd.
[root@dhg3 hoemann]# systemctl status kdump
kdump.service - Crash recovery kernel arming
Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled)
Active: failed (Result: start-limit) since Tue 2014-04-22 17:02:56 MDT; 59min ago
Process: 8803 ExecStop=/usr/bin/kdumpctl stop (code=exited, status=0/SUCCESS)
Process: 8911 ExecStart=/usr/bin/kdumpctl start (code=killed, signal=TERM)
Main PID: 8911 (code=killed, signal=TERM)
Apr 22 17:02:56 dhg3 systemd[1]: Starting Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: Stopping Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: Starting Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: kdump.service start request repeated too quickly, refusing to start.
Apr 22 17:02:56 dhg3 systemd[1]: Failed to start Crash recovery kernel arming.
Apr 22 17:02:56 dhg3 systemd[1]: Unit kdump.service entered failed state.
The ratelimiting can be disabled by adding StartLimitInterval=0 to the kdump
service file.
Cc: Vivek Goyal <vgoyal(a)redhat.com>
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
---
kdump.service | 1 +
1 file changed, 1 insertion(+)
diff --git a/kdump.service b/kdump.service
index 55b7ca2..24c1386 100644
--- a/kdump.service
+++ b/kdump.service
@@ -7,6 +7,7 @@ Type=oneshot
ExecStart=/usr/bin/kdumpctl start
ExecStop=/usr/bin/kdumpctl stop
RemainAfterExit=yes
+StartLimitInterval=0
[Install]
WantedBy=multi-user.target
--
1.8.5.3
9 years, 11 months
[PATCH] Fix kdump udev memory event restarts
by Prarit Bhargava
During debugging of another problem issues were noted with the kdump udev
rules. The kdump service is restarted on memory add and remove events.
These are the wrong events for these types of devices and result in an overly
aggressive restarting of the kdump service.
There are four udev events to consider, "add", "remove", "online", and
"offline". The remove event is a complete removal from the system -- neither
the hardware nor the kernel know about the hardware; it has been physically
removed. The add event is associated with hardware being physically added to
the system. The kernel has some limited knowledge of the device, however,
it is not avaiable for the kernel to use until it is brought online. Online
events refer to the device being available for the kernel to use. Opposite
to that is the offline event, which occurs when a device is no longer in
use by the kernel.
Note that in all four events the kernel *may* have some remaining information
stored about the device.
In the case of memory hotplug, kdump should be restarted when a memory module
is onlined or offlined. This is because the memory is not in use by the
kernel until the memory is onlined, and it is unused when the memory is
offlined.
Making these modifications results in smooth service on systems that do
heavy memory onlining and offlining.
Cc: Vivek Goyal <vgoyal(a)redhat.com>
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
---
98-kexec.rules | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/98-kexec.rules b/98-kexec.rules
index 8c742dd..162260d 100644
--- a/98-kexec.rules
+++ b/98-kexec.rules
@@ -1,4 +1,4 @@
SUBSYSTEM=="cpu", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"
SUBSYSTEM=="cpu", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service"
-SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service"
-SUBSYSTEM=="memory", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service"
--
1.8.5.3
9 years, 11 months
[PATCH] Add some missing variables to default sysconfig and kdumpctl
by Dave Young
When I testing arm kdump, the kdump start failed with several missing variables
Copy them from x86 sysconfig to general sysconfig so at least user can set
the right value in sysconfig
Also It's better to add them to the beggining of kdumpctl and initilize them
as nul, later sourcing sysconfig will overwite them.
Signed-off-by: Dave Young <dyoung(a)redhat.com>
---
kdump.sysconfig | 9 +++++++++
kdumpctl | 3 +++
2 files changed, 12 insertions(+)
--- kexec-tools.orig/kdump.sysconfig
+++ kexec-tools/kdump.sysconfig
@@ -24,3 +24,12 @@ KDUMP_COMMANDLINE_APPEND="irqpoll maxcpu
# Example:
# KEXEC_ARGS="--elf32-core-headers"
KEXEC_ARGS=""
+
+#Where to find the boot image
+KDUMP_BOOTDIR="/boot"
+
+#What is the image type used for kdump
+KDUMP_IMG=""
+
+#What is the images extension. Relocatable kernels don't have one
+KDUMP_IMG_EXT=""
--- kexec-tools.orig/kdumpctl
+++ kexec-tools/kdumpctl
@@ -9,6 +9,9 @@ MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
DUMP_TARGET=""
+KDUMP_BOOTDIR=""
+KDUMP_IMG=""
+KDUMP_IMG_EXT=""
. /lib/kdump/kdump-lib.sh
9 years, 11 months
[PATCH] Add a anaconda addon to configurate kdump in the system installation process
by Arthur Zou
Currently this work is done by firstboot. Now we move to anaconda addon
to configurate in the system installation process.
Signed-off-by: Arthur Zou <zzou(a)redhat.com>
---
addon-Makefile | 82 ++++++++++++
addon-README | 32 +++++
addon-__init__.py | 0
addon-common.py | 88 ++++++++++++
addon-constants.py | 23 ++++
addon-gui-__init__.py | 0
addon-gui-spokes-__init__.py | 0
addon-gui-spokes-fedora.glade | 218 ++++++++++++++++++++++++++++++
addon-gui-spokes-kdump.glade | 274 ++++++++++++++++++++++++++++++++++++++
addon-gui-spokes-kdump.py | 192 ++++++++++++++++++++++++++
addon-i18n.py | 27 ++++
addon-ks-__init__.py | 0
addon-ks-kdump.py | 128 ++++++++++++++++++
addon-po-Makefile | 78 +++++++++++
addon-po-kdump-anaconda-addon.pot | 81 +++++++++++
addon-tui-__init__.py | 0
addon-tui-spokes-__init__.py | 0
addon-tui-spokes-kdump.py | 87 ++++++++++++
18 files changed, 1310 insertions(+)
create mode 100644 addon-Makefile
create mode 100644 addon-README
create mode 100644 addon-__init__.py
create mode 100644 addon-common.py
create mode 100644 addon-constants.py
create mode 100644 addon-gui-__init__.py
create mode 100644 addon-gui-spokes-__init__.py
create mode 100644 addon-gui-spokes-fedora.glade
create mode 100644 addon-gui-spokes-kdump.glade
create mode 100644 addon-gui-spokes-kdump.py
create mode 100644 addon-i18n.py
create mode 100644 addon-ks-__init__.py
create mode 100644 addon-ks-kdump.py
create mode 100644 addon-po-Makefile
create mode 100644 addon-po-kdump-anaconda-addon.pot
create mode 100644 addon-tui-__init__.py
create mode 100644 addon-tui-spokes-__init__.py
create mode 100644 addon-tui-spokes-kdump.py
diff --git a/addon-Makefile b/addon-Makefile
new file mode 100644
index 0000000..74415bd
--- /dev/null
+++ b/addon-Makefile
@@ -0,0 +1,82 @@
+NAME = kdump-anaconda-addon
+
+VERSION = 0.1
+
+ADDON = com_redhat_kdump
+TESTS = test
+
+FILES = $(ADDON) \
+ $(TESTS) \
+ po \
+ LICENSE \
+ Makefile \
+ README
+
+EXCLUDES = \
+ *~ \
+ *.pyc
+
+all:
+ @echo "usage: make dist"
+ @echo " make test"
+ @echo " make install"
+ @echo " make uninstall"
+
+DISTNAME = $(NAME)-$(VERSION)
+ADDONDIR = /usr/share/anaconda/addons/
+DISTBALL = $(DISTNAME).tar.gz
+NUM_PROCS = $$(getconf _NPROCESSORS_ONLN)
+
+install:
+ mkdir -p $(DESTDIR)$(ADDONDIR)
+ cp -rv $(ADDON) $(DESTDIR)$(ADDONDIR)
+
+uninstall:
+ rm -rfv $(DESTDIR)$(ADDONDIR)
+
+dist:
+ rm -rf $(DISTNAME)
+ mkdir -p $(DISTNAME)
+ @if test -d ".git"; \
+ then \
+ echo Creating ChangeLog && \
+ ( cd "$(top_srcdir)" && \
+ echo '# Generate automatically. Do not edit.'; echo; \
+ git log --stat --date=short ) > ChangeLog.tmp \
+ && mv -f ChangeLog.tmp $(DISTNAME)/ChangeLog \
+ || ( rm -f ChangeLog.tmp ; \
+ echo Failed to generate ChangeLog >&2 ); \
+ else \
+ echo A git clone is required to generate a ChangeLog >&2; \
+ fi
+ for file in $(FILES); do \
+ cp -rpv $$file $(DISTNAME)/$$file; \
+ done
+ for excl in $(EXCLUDES); do \
+ find $(DISTNAME) -name "$$excl" -delete; \
+ done
+ tar -czvf $(DISTBALL) $(DISTNAME)
+ rm -rf $(DISTNAME)
+
+potfile:
+ $(MAKE) DESTDIR=$(DESTDIR) -C po potfile
+
+po-pull:
+ tx pull -a --disable-overwrite
+
+install-po-files:
+ $(MAKE) -C po install
+
+test:
+ @echo "***Running pylint checks***"
+ @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null
+ @echo "[ OK ]"
+ @echo "***Running unittests checks***"
+ @PYTHONPATH=. nosetests --processes=-1 -vw tests/
+
+runpylint:
+ @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null
+ @echo "[ OK ]"
+
+unittest:
+ PYTHONPATH=. nosetests --processes=-1 -vw tests/
diff --git a/addon-README b/addon-README
new file mode 100644
index 0000000..fbd1cbd
--- /dev/null
+++ b/addon-README
@@ -0,0 +1,32 @@
+This is an anaconda addon for configuring kdump. To use, copy the
+com_redhat_kdump directory into /usr/share/anaconda/addons on your
+installation media. /etc/kdump.conf will also be needed in the installation
+environment to provide the default contents of /etc/kdump.conf on the
+installed system.
+
+The syntax of the addon's kickstart section is:
+
+%addon com_redhat_kdump (--enable|--disable) --reserve-mb=("auto"|<amount>)
+<contents of /etc/kdump.conf>
+%end
+
+Note that support for arguments on the %addon line was added in
+anaconda-21.23. See anaconda commit 3a512e4f9e15977f0ce2d0bbe39e841b881398f3,
+https://bugzilla.redhat.com/show_bug.cgi?id=1065674
+
+How to test the kdump-anaconda-addon?
+You can provide an updates image in the kernel boot arguments as updates=,
+and the contents will be added to the stage2 filesystem.
+https://fedoraproject.org/wiki/Anaconda/Updates has more details, but usually
+the easiest is to make it available via HTTP or FTP and provide a url to updates=.
+
+The file is a gzip-compressed cpio archive, and the files need to be put into
+stage2 in /usr/share/anaconda/addons, so something like this will work to create
+an updates.img:
+
+mkdir -p updates/usr/share/anaconda/addons
+cp -r com_redhat_kdump updates/usr/share/anaconda/addons/
+( cd updates; find . | cpio -oc | gzip -c9 ) > updates.img
+
+then you can upload the updates.img to some http or ftp server so the anaconda
+can get it by boot parameter as updates=http://some.website.com/path/to/updates.img.
diff --git a/addon-__init__.py b/addon-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-common.py b/addon-common.py
new file mode 100644
index 0000000..cd37131
--- /dev/null
+++ b/addon-common.py
@@ -0,0 +1,88 @@
+# Kdump configuration common methods
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+import os
+__all__ = ["getReservedMemory", "getTotalMemory", "getMemoryBounds", "getOS"]
+
+from pyanaconda.isys import total_memory
+from pyanaconda.flags import flags
+from com_redhat_kdump.constants import OS_RELEASE
+
+_reservedMemory = None
+def getReservedMemory():
+ """Return the amount of memory currently reserved for kdump in MB."""
+ global _reservedMemory
+
+ # Check if the value has already been read
+ if _reservedMemory is not None:
+ return _reservedMemory
+
+ try:
+ with open("/sys/kernel/kexec_crash_size", "r") as fobj:
+ _reservedMemory = int(fobj.read()) / (1024*1024)
+ return _reservedMemory
+ except (ValueError, IOError):
+ return 0
+
+def getTotalMemory():
+ """Return the total amount of system memory in MB
+
+ This is the amount reported by /proc/meminfo plus the aount
+ currently reserved for kdump.
+ """
+
+ # total_memory return memory in KB, convert to MB
+ availMem = total_memory() / 1024
+
+ return availMem + getReservedMemory()
+
+def getMemoryBounds():
+ """Return a tuple of (lower, upper, step) for kdump reservation limits.
+
+ If there is not enough memory available to use kdump, both lower and
+ upper will be 0.
+ """
+
+ totalMemory = getTotalMemory()
+
+ if flags.targetarch == 'ppc64':
+ lowerBound = 256
+ minUsable = 1024
+ step = 1
+ else:
+ lowerBound = 128
+ minUsable = 256
+ step = 1
+
+ upperBound = (totalMemory - minUsable) - (totalMemory % step)
+
+ if upperBound < lowerBound:
+ upperBound = lowerBound = 0
+
+ return (lowerBound, upperBound, step)
+
+def getOS():
+ with open(os.path.normpath(OS_RELEASE), "r") as fobj:
+ line = fobj.readline()
+
+ if not "Fedora" in line:
+ return "redhat"
+ else:
+ return "fedora"
diff --git a/addon-constants.py b/addon-constants.py
new file mode 100644
index 0000000..aab9537
--- /dev/null
+++ b/addon-constants.py
@@ -0,0 +1,23 @@
+# Kdump configuration constants
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+# The location of the kdump config file
+OS_RELEASE = "/etc/os-release"
diff --git a/addon-gui-__init__.py b/addon-gui-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-gui-spokes-__init__.py b/addon-gui-spokes-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-gui-spokes-fedora.glade b/addon-gui-spokes-fedora.glade
new file mode 100644
index 0000000..c416259
--- /dev/null
+++ b/addon-gui-spokes-fedora.glade
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface domain="kdump-anaconda-addon">
+ <requires lib="gtk+" version="3.6"/>
+ <!-- interface-requires AnacondaWidgets 1.0 -->
+ <object class="AnacondaSpokeWindow" id="KdumpWindow">
+ <property name="startup_id">filler</property>
+ <property name="can_focus">False</property>
+ <property name="startup_id">filler</property>
+ <property name="window_name" translatable="yes">KDUMP</property>
+ <signal name="button-clicked" handler="on_back_clicked" swapped="no"/>
+ <child internal-child="main_box">
+ <object class="GtkBox" id="AnacondaSpokeWindow-main_box1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child internal-child="nav_box">
+ <object class="GtkEventBox" id="AnacondaSpokeWindow-nav_box1">
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="nav_area">
+ <object class="GtkGrid" id="AnacondaSpokeWindow-nav_area1">
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="alignment">
+ <object class="GtkAlignment" id="AnacondaSpokeWindow-alignment1">
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <child internal-child="action_area">
+ <object class="GtkBox" id="AnacondaSpokeWindow-action_area1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="summaryLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Kdump is a kernel crash dumping mechanism. In the event of a system crash, kdump will capture information from your system that can be invaluable in determining the cause of the crash. Note that kdump does require reserving a portion of system memory that will be unavailable for other uses.</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="toBeReservedLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Memory To Be Reserved (MB):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">toBeReservedSpin</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="toBeReservedSpin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">digits</property>
+ <property name="update_policy">if-valid</property>
+ <signal name="value-changed" handler="on_reserved_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Total System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Usable System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="enableKdumpCheck">
+ <property name="label" translatable="yes">_Enable kdump?</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_enable_kdump_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/addon-gui-spokes-kdump.glade b/addon-gui-spokes-kdump.glade
new file mode 100644
index 0000000..e0bd55f
--- /dev/null
+++ b/addon-gui-spokes-kdump.glade
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface domain="kdump-anaconda-addon">
+ <requires lib="gtk+" version="3.6"/>
+ <!-- interface-requires AnacondaWidgets 1.0 -->
+ <object class="AnacondaSpokeWindow" id="KdumpWindow">
+ <property name="startup_id">filler</property>
+ <property name="can_focus">False</property>
+ <property name="startup_id">filler</property>
+ <property name="window_name" translatable="yes">KDUMP</property>
+ <signal name="button-clicked" handler="on_back_clicked" swapped="no"/>
+ <child internal-child="main_box">
+ <object class="GtkBox" id="AnacondaSpokeWindow-main_box1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child internal-child="nav_box">
+ <object class="GtkEventBox" id="AnacondaSpokeWindow-nav_box1">
+ <property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
+ <child internal-child="nav_area">
+ <object class="GtkGrid" id="AnacondaSpokeWindow-nav_area1">
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="alignment">
+ <object class="GtkAlignment" id="AnacondaSpokeWindow-alignment1">
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <child internal-child="action_area">
+ <object class="GtkBox" id="AnacondaSpokeWindow-action_area1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">10</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="summaryLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Kdump is a kernel crash dumping mechanism. In the event of a system crash, kdump will capture information from your system that can be invaluable in determining the cause of the crash. Note that kdump does require reserving a portion of system memory that will be unavailable for other uses.</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkCheckButton" id="enableKdumpCheck">
+ <property name="label" translatable="yes">_Enable kdump?</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_enable_kdump_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">3</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="reservationTypeLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Kdump Memory Reservation:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="autoButton">
+ <property name="label" translatable="yes">_Automatic</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_reservation_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="manualButton">
+ <property name="label" translatable="yes">_Manual</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">autoButton</property>
+ <signal name="toggled" handler="on_reservation_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="toBeReservedLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Memory To Be Reserved (MB):</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">toBeReservedSpin</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="toBeReservedSpin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">digits</property>
+ <property name="update_policy">if-valid</property>
+ <signal name="value-changed" handler="on_reserved_value_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Total System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="totalMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Usable System Memory (MB):</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="usableMemMB">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/addon-gui-spokes-kdump.py b/addon-gui-spokes-kdump.py
new file mode 100644
index 0000000..7523acf
--- /dev/null
+++ b/addon-gui-spokes-kdump.py
@@ -0,0 +1,192 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+"""Kdump anaconda GUI configuration"""
+
+from gi.repository import Gtk
+
+from pyanaconda.ui.gui.categories.system import SystemCategory
+from pyanaconda.ui.gui.spokes import NormalSpoke
+from pyanaconda.ui.gui.utils import fancy_set_sensitive
+
+from com_redhat_kdump.i18n import _, N_
+from com_redhat_kdump.common import getReservedMemory, getTotalMemory, getMemoryBounds, getOS
+
+__all__ = ["KdumpSpoke"]
+
+class KdumpSpoke(NormalSpoke):
+ """Kdump configuration spoke"""
+
+ builderObjects = ["KdumpWindow", "advancedConfigBuffer"]
+ mainWidgetName = "KdumpWindow"
+ uiFile = "kdump.glade"
+ translationDomain = "kdump-anaconda-addon"
+
+ icon = "computer-fail-symbolic"
+ title = N_("_KDUMP")
+ category = SystemCategory
+ OS = "redhat"
+ def __init__(self, data, storage, payload, instclass):
+ KdumpSpoke.OS = getOS()
+ if KdumpSpoke.OS == "fedora":
+ KdumpSpoke.uiFile = "fedora.glade"
+ NormalSpoke.__init__(self, data, storage, payload, instclass)
+ self._reserveMem = 0
+
+ def initialize(self):
+ NormalSpoke.initialize(self)
+ self._enableButton = self.builder.get_object("enableKdumpCheck")
+ KdumpSpoke.OS = getOS()
+ if KdumpSpoke.OS == "redhat":
+ self._reservationTypeLabel = self.builder.get_object("reservationTypeLabel")
+ self._autoButton = self.builder.get_object("autoButton")
+ self._manualButton = self.builder.get_object("manualButton")
+
+ self._toBeReservedLabel = self.builder.get_object("toBeReservedLabel")
+ self._toBeReservedSpin = self.builder.get_object("toBeReservedSpin")
+ self._totalMemLabel = self.builder.get_object("totalMemLabel")
+ self._totalMemMB = self.builder.get_object("totalMemMB")
+ self._usableMemLabel = self.builder.get_object("usableMemLabel")
+ self._usableMemMB = self.builder.get_object("usableMemMB")
+
+ # Set an initial value and adjustment on the spin button
+ lower, upper, step = getMemoryBounds()
+ adjustment = Gtk.Adjustment(lower, lower, upper, step, step, 0)
+ self._toBeReservedSpin.set_adjustment(adjustment)
+ self._toBeReservedSpin.set_value(lower)
+
+ def refresh(self):
+ # If a reserve amount is requested, set it in the spin button
+ if self.data.addons.com_redhat_kdump.reserveMB != "auto":
+ # Strip the trailing 'M'
+ reserveMB = self.data.addons.com_redhat_kdump.reserveMB
+ if reserveMB and reserveMB[-1] == 'M':
+ reserveMB = reserveMB[:-1]
+ if reserveMB:
+ self._toBeReservedSpin.set_value(int(reserveMB))
+
+ # Set the various labels. Use the spin button signal handler to set the
+ # usable memory label once the other two have been set.
+ self._totalMemMB.set_text("%d" % getTotalMemory())
+ self._toBeReservedSpin.emit("value-changed")
+
+ # Set the states on the toggle buttons and let the signal handlers set
+ # the sensitivities on the related widgets. Set the radio button first,
+ # since the radio buttons' bailiwick is a subset of that of the
+ # enable/disable checkbox.
+ if KdumpSpoke.OS == "redhat":
+ if self.data.addons.com_redhat_kdump.reserveMB == "auto":
+ self._autoButton.set_active(True)
+ self._manualButton.set_active(False)
+ else:
+ self._autoButton.set_active(False)
+ self._manualButton.set_active(True)
+
+ if self.data.addons.com_redhat_kdump.enabled:
+ self._enableButton.set_active(True)
+ else:
+ self._enableButton.set_active(False)
+
+ # Force a toggled signal on the button in case it's state has not changed
+ self._enableButton.emit("toggled")
+
+ def apply(self):
+ # Copy the GUI state into the AddonData object
+ self.data.addons.com_redhat_kdump.enabled = self._enableButton.get_active()
+
+ if KdumpSpoke.OS == "redhat" and self._autoButton.get_active():
+ reserveMem = "auto"
+ else:
+ reserveMem = "%dM" % self._toBeReservedSpin.get_value_as_int()
+
+ self.data.addons.com_redhat_kdump.reserveMB = reserveMem
+
+
+ @property
+ def ready(self):
+ return True
+
+ @property
+ def completed(self):
+ # Always treat as completed
+ return True
+
+ @property
+ def mandatory(self):
+ return False
+
+ @property
+ def status(self):
+ if self.data.addons.com_redhat_kdump.enabled:
+ state = _("Kdump is enabled")
+ else:
+ state = _("Kdump is disabled")
+
+ return state
+
+ # SIGNAL HANDLERS
+
+ def on_enable_kdump_toggled(self, checkbutton, user_data=None):
+ status = checkbutton.get_active()
+
+ # If disabling, set everything to insensitve. Otherwise, only set the radio
+ # button and currently reserved widgets to sensitive and then fake a
+ # toggle event on the radio button to set the state on the reserve
+ # amount spin button and total/usable mem display.
+ if KdumpSpoke.OS == "redhat":
+ self._autoButton.set_sensitive(status)
+ self._manualButton.set_sensitive(status)
+ self._reservationTypeLabel.set_sensitive(status)
+
+ if not status:
+ fancy_set_sensitive(self._toBeReservedSpin, status)
+ self._totalMemLabel.set_sensitive(status)
+ self._totalMemMB.set_sensitive(status)
+ self._usableMemLabel.set_sensitive(status)
+ self._usableMemMB.set_sensitive(status)
+ elif KdumpSpoke.OS == "redhat":
+ self._autoButton.emit("toggled")
+ else:
+ fancy_set_sensitive(self._toBeReservedSpin, True)
+ self._totalMemLabel.set_sensitive(True)
+ self._totalMemMB.set_sensitive(True)
+ self._usableMemLabel.set_sensitive(True)
+ self._usableMemMB.set_sensitive(True)
+
+ def on_reservation_toggled(self, radiobutton, user_data=None):
+ status = self._manualButton.get_active()
+
+ # If setting to auto, disable the manual config spinner and
+ # the total/usable memory labels
+ fancy_set_sensitive(self._toBeReservedSpin, status)
+ self._totalMemLabel.set_sensitive(status)
+ self._totalMemMB.set_sensitive(status)
+ self._usableMemLabel.set_sensitive(status)
+ self._usableMemMB.set_sensitive(status)
+
+ def on_reserved_value_changed(self, spinbutton, user_data=None):
+ reserveMem = spinbutton.get_value_as_int()
+ totalMemText = self._totalMemMB.get_text()
+
+ # If no total memory is available yet, do nothing
+ if totalMemText:
+ totalMem = int(self._totalMemMB.get_text())
+ self._usableMemMB.set_text("%d" % (totalMem - reserveMem))
diff --git a/addon-i18n.py b/addon-i18n.py
new file mode 100644
index 0000000..a8cd27a
--- /dev/null
+++ b/addon-i18n.py
@@ -0,0 +1,27 @@
+# Kdump configuration translation functions
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+__all__ = ["_", "N_"]
+
+import gettext
+
+_ = lambda x: gettext.ldgettext("kdump-anaconda-addon", x)
+N_ = lambda x: x
diff --git a/addon-ks-__init__.py b/addon-ks-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-ks-kdump.py b/addon-ks-kdump.py
new file mode 100644
index 0000000..b4b346c
--- /dev/null
+++ b/addon-ks-kdump.py
@@ -0,0 +1,128 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2014 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+import os
+
+from pyanaconda.addons import AddonData
+from pyanaconda.constants import ROOT_PATH
+from pyanaconda import iutil
+
+from pykickstart.options import KSOptionParser
+from pykickstart.errors import KickstartParseError, formatErrorMsg
+from com_redhat_kdump.common import getOS, getMemoryBounds
+from com_redhat_kdump.i18n import _
+
+__all__ = ["KdumpData"]
+
+class KdumpData(AddonData):
+ """Addon data for the kdump configuration"""
+
+ def __init__(self, name):
+ AddonData.__init__(self, name)
+
+ self.enabled = True
+ self.reserveMB = "auto"
+ if getOS() == "fedora":
+ self.enabled = False
+ lower, upper, step = getMemoryBounds()
+ self.reserveMB = "%d" % lower
+
+ def __str__(self):
+ addon_str = "%%addon %s" % self.name
+
+ if self.enabled:
+ addon_str += " --enable"
+ else:
+ addon_str += " --disable"
+
+ if self.reserveMB:
+ addon_str += " --reserve-mb='%s'" % self.reserveMB
+
+ addon_str += "\n%s\n%%end\n" % self.content.strip()
+
+ return addon_str
+
+ def setup(self, storage, ksdata, instClass):
+ # Clear any existing crashkernel bootloader arguments
+ if ksdata.bootloader.appendLine:
+ ksdata.bootloader.appendLine = ' '.join(
+ (arg for arg in ksdata.bootloader.appendLine.split() \
+ if not arg.startswith('crashkernel=')))
+
+ # Copy our reserved amount to the bootloader arguments
+ if self.enabled:
+ # Ensure that the amount is "auto" or an amount in MB
+ if self.reserveMB != "auto" and self.reserveMB[-1] != 'M':
+ self.reserveMB += 'M'
+ ksdata.bootloader.appendLine += ' crashkernel=%s' % self.reserveMB
+
+ # Do the same thing with the storage.bootloader.boot_args set
+ if storage.bootloader.boot_args:
+ crashargs = [arg for arg in storage.bootloader.boot_args \
+ if arg.startswith('crashkernel=')]
+ storage.bootloader.boot_args -= set(crashargs)
+
+ if self.enabled:
+ storage.bootloader.boot_args.add('crashkernel=%s' % self.reserveMB)
+ ksdata.packages.packageList.append("kexec-tools")
+
+ def handle_header(self, lineno, args):
+ op = KSOptionParser()
+ op.add_option("--enable", action="store_true", default=True,
+ dest="enabled", help="Enable kdump")
+ op.add_option("--disable", action="store_false",
+ dest="enabled", help="Disable kdump")
+ op.add_option("--reserve-mb", type="string", dest="reserveMB",
+ default="auto", help="Amount of memory in MB to reserve for kdump, or auto")
+
+ (opts, extra) = op.parse_args(args=args, lineno=lineno)
+
+ # Reject any additional arguments
+ if extra:
+ AddonData.handle_header(self, lineno, extra)
+
+ # Validate the reserve-mb argument
+ if opts.reserveMB != "auto":
+ # Allow a final 'M' for consistency with the crashkernel kernel
+ # parameter. Strip it if found.
+ if opts.reserveMB and opts.reserveMB[-1] == 'M':
+ opts.reserveMB = opts.reserveMB[:-1]
+
+ try:
+ _test = int(opts.reserveMB)
+ except ValueError:
+ msg = _("Invalid value %s for --reserve-mb") % opts.reserveMB
+ if lineno != None:
+ raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
+ else:
+ raise KickstartParseError(msg)
+
+ # Store the parsed arguments
+ self.enabled = opts.enabled
+ self.reserveMB =opts.reserveMB
+
+ def execute(self, storage, ksdata, instClass, users):
+ if self.enabled:
+ action = "enable"
+ else:
+ action = "disable"
+
+ iutil.execWithRedirect("systemctl", [action, "kdump.service"], root=ROOT_PATH)
diff --git a/addon-po-Makefile b/addon-po-Makefile
new file mode 100644
index 0000000..508b7e9
--- /dev/null
+++ b/addon-po-Makefile
@@ -0,0 +1,78 @@
+#
+# Makefile for the PO files (translation) catalog
+#
+# $Id$
+
+TOP = ../..
+
+# What is this package?
+NLSPACKAGE = kdump-anaconda-addon
+POTFILE = $(NLSPACKAGE).pot
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = $(INSTALL) -m 644
+INSTALL_DIR = /usr/bin/install -d
+
+# destination directory
+INSTALL_NLS_DIR = $(DESTDIR)/usr/share/locale
+# PO catalog handling
+MSGMERGE = msgmerge -v
+XGETTEXT = xgettext --default-domain=$(NLSPACKAGE) \
+ --add-comments
+MSGFMT = msgfmt --statistics --verbose
+
+# What do we need to do
+POFILES = $(wildcard *.po)
+MOFILES = $(patsubst %.po,%.mo,$(POFILES))
+PYSRC = $(wildcard ../com_redhat_kdump/*.py ../com_redhat_kdump/*/*.py ../com_redhat_kdump/*/*/*.py)
+GLADEFILES = $(wildcard ../com_redhat_kdump/gui/spokes/*.glade)
+
+all:: update-po $(MOFILES)
+
+potfile: $(PYSRC) glade-po
+ $(XGETTEXT) -L Python --keyword=_ --keyword=N_ $(PYSRC) tmp/*.h
+ @if cmp -s $(NLSPACKAGE).po $(POTFILE); then \
+ rm -f $(NLSPACKAGE).po; \
+ else \
+ mv -f $(NLSPACKAGE).po $(POTFILE); \
+ fi; \
+ rm -rf tmp/
+
+glade-po: $(GLADEFILES)
+ rm -rf tmp/
+ for f in $(GLADEFILES); do \
+ intltool-extract --type=gettext/glade -l $$f ;\
+ done
+
+update-po: Makefile refresh-po
+
+refresh-po: Makefile
+ for cat in $(POFILES); do \
+ lang=`basename $$cat .po`; \
+ if $(MSGMERGE) $$lang.po $(POTFILE) > $$lang.pot ; then \
+ mv -f $$lang.pot $$lang.po ; \
+ echo "$(MSGMERGE) of $$lang succeeded" ; \
+ else \
+ echo "$(MSGMERGE) of $$lang failed" ; \
+ rm -f $$lang.pot ; \
+ fi \
+ done
+
+clean:
+ @rm -fv *mo *~ .depend
+ @rm -rf tmp
+
+install: $(MOFILES)
+ @for n in $(MOFILES); do \
+ l=`basename $$n .mo`; \
+ $(INSTALL_DIR) $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES; \
+ $(INSTALL_DATA) --verbose $$n $(INSTALL_NLS_DIR)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
+ done
+
+uninstall:
+ rm -rfv $(INSTALL_NLS_DIR)/*/LC_MESSAGES/$(NLSPACKAGE).mo
+
+%.mo: %.po
+ $(MSGFMT) -o $@ $<
+
+.PHONY: missing depend
+
diff --git a/addon-po-kdump-anaconda-addon.pot b/addon-po-kdump-anaconda-addon.pot
new file mode 100644
index 0000000..3b9b641
--- /dev/null
+++ b/addon-po-kdump-anaconda-addon.pot
@@ -0,0 +1,81 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-04-09 15:07+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL(a)li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../com_redhat_kdump/ks/kdump.py:112
+#, python-format
+msgid "Invalid value %s for --reserve-mb"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:56
+msgid "Kdump"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:84
+#: ../com_redhat_kdump/gui/spokes/kdump.py:138
+msgid "Kdump is enabled"
+msgstr ""
+
+#: ../com_redhat_kdump/tui/spokes/kdump.py:86
+#: ../com_redhat_kdump/gui/spokes/kdump.py:140
+msgid "Kdump is disabled"
+msgstr ""
+
+#: ../com_redhat_kdump/gui/spokes/kdump.py:43
+msgid "_KDUMP"
+msgstr ""
+
+#: tmp/fedora.glade.h:1 tmp/kdump.glade.h:1
+msgid "KDUMP"
+msgstr ""
+
+#: tmp/fedora.glade.h:2 tmp/kdump.glade.h:2
+msgid ""
+"Kdump is a kernel crash dumping mechanism. In the event of a system crash, "
+"kdump will capture information from your system that can be invaluable in "
+"determining the cause of the crash. Note that kdump does require reserving a "
+"portion of system memory that will be unavailable for other uses."
+msgstr ""
+
+#: tmp/fedora.glade.h:3 tmp/kdump.glade.h:7
+msgid "Memory To Be Reserved (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:4 tmp/kdump.glade.h:8
+msgid "Total System Memory (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:5 tmp/kdump.glade.h:9
+msgid "Usable System Memory (MB):"
+msgstr ""
+
+#: tmp/fedora.glade.h:6 tmp/kdump.glade.h:3
+msgid "_Enable kdump?"
+msgstr ""
+
+#: tmp/kdump.glade.h:4
+msgid "Kdump Memory Reservation:"
+msgstr ""
+
+#: tmp/kdump.glade.h:5
+msgid "_Automatic"
+msgstr ""
+
+#: tmp/kdump.glade.h:6
+msgid "_Manual"
+msgstr ""
diff --git a/addon-tui-__init__.py b/addon-tui-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-tui-spokes-__init__.py b/addon-tui-spokes-__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/addon-tui-spokes-kdump.py b/addon-tui-spokes-kdump.py
new file mode 100644
index 0000000..23e8040
--- /dev/null
+++ b/addon-tui-spokes-kdump.py
@@ -0,0 +1,87 @@
+# Kdump anaconda configuration
+#
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea(a)redhat.com>
+#
+
+"""Kdump anaconda TUI configuration"""
+
+import re
+
+from pyanaconda.ui.tui.spokes import EditTUISpoke
+from pyanaconda.ui.tui.spokes import EditTUISpokeEntry as Entry
+from com_redhat_kdump.common import getOS, getMemoryBounds
+from com_redhat_kdump.i18n import N_, _
+
+__all__ = ["KdumpSpoke"]
+
+class _re:
+ def __init__(self, patten, low, up):
+ self.re = re.compile(patten)
+ self.low = low
+ self.up = up
+
+ def match(self, key):
+ if self.re.match(key):
+ if key == "auto":
+ return True
+ if key[-1] == 'M':
+ key = key[:-1]
+ key = int(key)
+ if key <= self.up and key >= self.low :
+ return True
+ return False
+
+lower, upper ,step = getMemoryBounds()
+# Allow either "auto" or a string of digits optionally followed by 'M'
+RESERVE_VALID = _re(r'^((auto)|(\d+M?))$', lower, upper)
+FEDORA_RESERVE_VALID = _re(r'^(\d+M?)$', lower, upper)
+
+class KdumpSpoke(EditTUISpoke):
+ title = N_("Kdump")
+ category = "system"
+
+ edit_fields = [
+ Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
+ Entry("Reserve amount", "reserveMB", RESERVE_VALID, lambda self,args: args.enabled)
+ ]
+
+ def __init__(self, app, data, storage, payload, instclass):
+ if getOS() == "fedora":
+ KdumpSpoke.edit_fields = [
+ Entry("Enable kdump", "enabled", EditTUISpoke.CHECK, True),
+ Entry("Reserve amount", "reserveMB", FEDORA_RESERVE_VALID, lambda self,args: args.enabled)
+ ]
+
+ EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
+ self.args = self.data.addons.com_redhat_kdump
+
+ def apply(self):
+ pass
+
+ @property
+ def completed(self):
+ return True
+
+ @property
+ def status(self):
+ if self.args.enabled:
+ state = _("Kdump is enabled")
+ else:
+ state = _("Kdump is disabled")
+ return state
--
1.8.4.2
9 years, 11 months
[PATCH] Fix kexec issues with cpu hotplug
by Prarit Bhargava
When doing cpu softplug via /sys
ie)
echo 0 > /sys/devices/system/cpu/cpuX/online
echo 1 > /sys/devices/system/cpu/cpuX/online
the kdump service eventually stops because it is rate limited by systemd.
[root@dhg3 hoemann]# systemctl status kdump
kdump.service - Crash recovery kernel arming
Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled)
Active: failed (Result: start-limit) since Tue 2014-04-22 17:02:56 MDT; 59min ago
Process: 8803 ExecStop=/usr/bin/kdumpctl stop (code=exited, status=0/SUCCESS)
Process: 8911 ExecStart=/usr/bin/kdumpctl start (code=killed, signal=TERM)
Main PID: 8911 (code=killed, signal=TERM)
Apr 22 17:02:56 dhg3 systemd[1]: Starting Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: Stopping Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: Starting Crash recovery kernel arming...
Apr 22 17:02:56 dhg3 systemd[1]: kdump.service start request repeated too quickly, refusing to start.
Apr 22 17:02:56 dhg3 systemd[1]: Failed to start Crash recovery kernel arming.
Apr 22 17:02:56 dhg3 systemd[1]: Unit kdump.service entered failed state.
The ratelimiting can be disabled by adding StartLimitInterval=0 to the kdump
service file.
During debugging of this issue additional issues were noted with the udev
rules. The first is the handling of the add & remove states for cpus. CPUs
are added and removed when they are brought into service. kdump, however,
does not need to restart during the add and remove but needs to restart
only when the CPUs memory is allocated or free'd during an online or offline.
Similarily, when memory modules are onlined and offlined the memory is not
made available for use by the kernel. It does not make sense to restart
kdump until the modules are added and removed from the kernel so the memory
is actually in use or removed from use.
Signed-off-by: Prarit Bhargava <prarit(a)redhat.com>
Cc: Vivek Goyal <vgoyal(a)redhat.com>
---
98-kexec.rules | 8 ++++----
kdump.service | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/98-kexec.rules b/98-kexec.rules
index 8c742dd..e32ee13 100644
--- a/98-kexec.rules
+++ b/98-kexec.rules
@@ -1,4 +1,4 @@
-SUBSYSTEM=="cpu", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"
-SUBSYSTEM=="cpu", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service"
-SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service"
-SUBSYSTEM=="memory", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="cpu", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="cpu", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"
+SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service"
diff --git a/kdump.service b/kdump.service
index 55b7ca2..24c1386 100644
--- a/kdump.service
+++ b/kdump.service
@@ -7,6 +7,7 @@ Type=oneshot
ExecStart=/usr/bin/kdumpctl start
ExecStop=/usr/bin/kdumpctl stop
RemainAfterExit=yes
+StartLimitInterval=0
[Install]
WantedBy=multi-user.target
--
1.8.5.3
9 years, 11 months