From 750530de2ea812b8bb208fd82c790a9ea0a66d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Wed, 16 Aug 2017 09:59:35 +0200 Subject: [PATCH] bootloader: Don't add nonexistent overlay image to grub.cfg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: rhbz#1454340 Signed-off-by: Ondřej Lysoněk --- tuned/plugins/plugin_bootloader.py | 7 +++++-- tuned/utils/commands.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_bootloader.py b/tuned/plugins/plugin_bootloader.py index 56c8c47..bfaf5ab 100644 --- a/tuned/plugins/plugin_bootloader.py +++ b/tuned/plugins/plugin_bootloader.py @@ -188,7 +188,8 @@ class BootloaderPlugin(base.Plugin): def _install_initrd(self, img): log.info("installing initrd image as '%s'" % self._initrd_dst_img_val) img_name = os.path.basename(self._initrd_dst_img_val) - self._cmd.copy(img, self._initrd_dst_img_val) + if not self._cmd.copy(img, self._initrd_dst_img_val): + return False self.update_grub2_cfg = True curr_cmdline = self._cmd.read_file("/proc/cmdline").rstrip() initrd_grubpath = "/" @@ -198,6 +199,7 @@ class BootloaderPlugin(base.Plugin): if len(path) < lc: initrd_grubpath = path self._initrd_val = os.path.join(initrd_grubpath, img_name) + return True @command_custom("grub2_cfg_file") def _grub2_cfg_file(self, enabling, value, verify, ignore_missing): @@ -237,7 +239,8 @@ class BootloaderPlugin(base.Plugin): self._init_initrd_dst_img(src_img) if src_img == "": return False - self._install_initrd(src_img) + if not self._install_initrd(src_img): + return False @command_custom("initrd_add_dir", per_device = False, priority = 10) def _initrd_add_dir(self, enabling, value, verify, ignore_missing): diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index f4379a8..084dc80 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -158,9 +158,11 @@ class commands: try: log.debug("copying file '%s' to '%s'" % (src, dst)) shutil.copy(src, dst) + return True except IOError as e: if not no_error: log.error("cannot copy file '%s' to '%s': %s" % (src, dst, e)) + return False def replace_in_file(self, f, pattern, repl): data = self.read_file(f)