diff --git a/SOURCES/tuned-2.14.0-cmdline-duplication-with-BLS-and-grub2-mkconfig-fix.patch b/SOURCES/tuned-2.14.0-cmdline-duplication-with-BLS-and-grub2-mkconfig-fix.patch new file mode 100644 index 0000000..de5d529 --- /dev/null +++ b/SOURCES/tuned-2.14.0-cmdline-duplication-with-BLS-and-grub2-mkconfig-fix.patch @@ -0,0 +1,95 @@ +From a0fd433e874a0fbdd8c43ae42d25969550311b9c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= +Date: Sun, 29 Nov 2020 21:34:15 +0100 +Subject: [PATCH] bootloader: fixed cmdline duplication with BLS and + grub2-mkconfig +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +After application of this patch in order to get rid of the duplicated +kernel command line options (which was duplicated due to the usage of +the grub2-mkconfig), the grub2-mkconfig needs to be run again. +We do not run it automatically in the spec file %post not to break +users not using grub2-mkconfig. + +This fix expects that user has not modified the line containing the +GRUB_CMDLINE_LINUX_DEFAULT option and the $tuned_params in the +/etc/default/grub file. If user modified this line, the option +duplication may still occure. In such case, please remove the +$tuned_params from the /etc/default/grub by hand. + +Resolves: rhbz#1777874 + +Signed-off-by: Jaroslav Škarvada +--- + tuned/plugins/plugin_bootloader.py | 34 +++++++++++++++++++++++++++++- + 1 file changed, 33 insertions(+), 1 deletion(-) + +diff --git a/tuned/plugins/plugin_bootloader.py b/tuned/plugins/plugin_bootloader.py +index 8ca5b8a1..416df7d6 100644 +--- a/tuned/plugins/plugin_bootloader.py ++++ b/tuned/plugins/plugin_bootloader.py +@@ -35,6 +35,7 @@ def _instance_init(self, instance): + self._cmdline_val = "" + self._initrd_val = "" + self._grub2_cfg_file_names = self._get_grub2_cfg_files() ++ self._bls = self._bls_enabled() + + def _instance_cleanup(self, instance): + pass +@@ -88,6 +89,15 @@ def _get_grub2_cfg_files(self): + cfg_files.append(f) + return cfg_files + ++ def _bls_enabled(self): ++ grub2_default_env = self._cmd.read_file(consts.GRUB2_DEFAULT_ENV_FILE) ++ if len(grub2_default_env) <= 0: ++ log.info("cannot read '%s'" % consts.GRUB2_DEFAULT_ENV_FILE) ++ return False ++ ++ return re.search(r"^\s*GRUB_ENABLE_BLSCFG\s*=\s*\"?\s*[tT][rR][uU][eE]\s*\"?\s*$", grub2_default_env, ++ flags = re.MULTILINE) is not None ++ + def _patch_bootcmdline(self, d): + return self._cmd.add_modify_option_in_file(consts.BOOT_CMDLINE_FILE, d) + +@@ -154,6 +164,25 @@ def _grub2_default_env_patch(self): + self._cmd.write_to_file(consts.GRUB2_DEFAULT_ENV_FILE, grub2_default_env) + return True + ++ def _grub2_default_env_unpatch(self): ++ grub2_default_env = self._cmd.read_file(consts.GRUB2_DEFAULT_ENV_FILE) ++ if len(grub2_default_env) <= 0: ++ log.info("cannot read '%s'" % consts.GRUB2_DEFAULT_ENV_FILE) ++ return False ++ ++ write = False ++ if re.search(r"^GRUB_CMDLINE_LINUX_DEFAULT=\"\$\{GRUB_CMDLINE_LINUX_DEFAULT:\+\$GRUB_CMDLINE_LINUX_DEFAULT \}\\\$" + ++ consts.GRUB2_TUNED_VAR + "\"$", grub2_default_env, flags = re.MULTILINE): ++ write = True ++ cfg = re.sub(r"^GRUB_CMDLINE_LINUX_DEFAULT=\"\$\{GRUB_CMDLINE_LINUX_DEFAULT:\+\$GRUB_CMDLINE_LINUX_DEFAULT \}\\\$" + ++ consts.GRUB2_TUNED_VAR + "\"$\n", "", grub2_default_env, flags = re.MULTILINE) ++ if cfg[-1] != "\n": ++ cfg += "\n" ++ if write: ++ log.debug("unpatching '%s'" % consts.GRUB2_DEFAULT_ENV_FILE) ++ self._cmd.write_to_file(consts.GRUB2_DEFAULT_ENV_FILE, cfg) ++ return True ++ + def _grub2_cfg_patch(self, d): + log.debug("patching grub.cfg") + if not self._grub2_cfg_file_names: +@@ -180,7 +209,10 @@ def _grub2_cfg_patch(self, d): + if patch_initial: + grub2_cfg_new = self._grub2_cfg_patch_initial(self._grub2_cfg_unpatch(grub2_cfg), d) + self._cmd.write_to_file(f, grub2_cfg_new) +- self._grub2_default_env_patch() ++ if self._bls: ++ self._grub2_default_env_unpatch() ++ else: ++ self._grub2_default_env_patch() + return True + + def _grub2_update(self): + diff --git a/SPECS/tuned.spec b/SPECS/tuned.spec index 05c108d..69e6b9b 100644 --- a/SPECS/tuned.spec +++ b/SPECS/tuned.spec @@ -34,7 +34,7 @@ Summary: A dynamic adaptive system tuning daemon Name: tuned Version: 2.14.0 -Release: 3%{?prerel1}%{?dist}.1 +Release: 3%{?prerel1}%{?dist}.2 License: GPLv2+ Source0: https://github.com/redhat-performance/%{name}/archive/v%{version}%{?prerel2}/%{name}-%{version}%{?prerel2}.tar.gz # RHEL-8 specific recommend.conf: @@ -78,6 +78,7 @@ Requires: python3-syspurpose Patch0: tuned-2.14.0-amd-performance-regression-fix.patch Patch1: tuned-2.14.0-scheduler-isolated-cores-cgroups-fix.patch Patch2: tuned-2.14.0-realtime-virtual-host-remove-lapic-advancement.patch +Patch3: tuned-2.14.0-cmdline-duplication-with-BLS-and-grub2-mkconfig-fix.patch %description The tuned package contains a daemon that tunes system settings dynamically. @@ -229,6 +230,7 @@ It can be also used to fine tune your system for specific scenarios. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 # Replace the upstream recommend.conf with a RHEL-8-specific one rm -f recommend.conf @@ -483,6 +485,10 @@ fi %{_mandir}/man7/tuned-profiles-compat.7* %changelog +* Tue Feb 2 2021 Jan Zerdik - 2.14.0-3.2 +- bootloader: fixed cmdline duplication with BLS and grub2-mkconfig + Resolves: rhbz#1918995 + * Fri Oct 2 2020 Jaroslav Škarvada - 2.14.0-3.1 - realtime-virtual-host: remove lapic advancement calculation and related qemu-kvm-tools-rhev requirement