Exemple #1
0
    def fix_dump_comp_initrd(self, plugin_obj, service, check):
        """Restart the dump service"""

        command = ["touch", "/etc/sysconfig/kdump"]
        execute_command(command)
        restart_service(service)
        re_check = plugin_obj.check_dump_component_in_initrd()
        if re_check.get_status():
            check.set_status(True)
            check.set_note(Notes.FIXED)
        else:
            check.set_note(Notes.FAIL_TO_FIX)
Exemple #2
0
    def check_dump_component_in_initrd(self):
        """Dump component in initial ramdisk"""

        status = True

        if not os.path.isfile(self.initial_ramdisk):
            self.log.error("Initial ramdisk not found %s",
                           self.initial_ramdisk)
            status = False

        elif get_file_size(self.initial_ramdisk) < 1:
            self.log.error("Initial ramdisk file is empty")
            status = False

        else:
            (return_code,
             stdout) = execute_command(["lsinitrd", self.initial_ramdisk])[:-1]

            if return_code is None:
                self.log.error(
                    "Failed to verify %s component in Initial ramdisk",
                    self.dump_comp_name)
                status = False

            elif self.dump_comp_name not in str(stdout):
                self.log.error("kdump component is missing in %s",
                               self.initial_ramdisk)
                status = False

            else:
                self.log.debug("%s component found in %s", self.dump_comp_name,
                               self.initial_ramdisk)

        return Check(self.check_dump_component_in_initrd.__doc__, status)
Exemple #3
0
    def get_mem_reserved(self):
        """Returns the size of memory reserved by fadump in MB"""

        fadump_mem_file = "/sys/kernel/fadump_mem_reserved"
        if os.path.exists(fadump_mem_file):
            fadump_mem = get_file_content(fadump_mem_file)
            if fadump_mem is None:
                self.log.debug("Unable to get fadump mem size from %s",
                               fadump_mem_file)
                return None
            else:
                try:
                    self.log.debug("%s: %s", fadump_mem_file, fadump_mem)
                    return int(fadump_mem) / 1024 / 1024
                except Exception:
                    self.log.debug("Invalid value (%s) found in %s file:",
                                   fadump_mem, fadump_mem_file)
            return None

        fadump_region_file = "/sys/kernel/debug/powerpc/fadump_region"
        if not os.path.exists(fadump_region_file):
            debugfs = "/sys/kernel/debug"
            command = ["mount", "-t", "debugfs", "nodev", debugfs]

            self.log.debug("Mounting %s", debugfs)
            if execute_command(command)[0] != 0:
                self.log.debug("Unable to mount %s", debugfs)
                return None

            if not os.path.exists(fadump_region_file):
                self.log.debug("%s file not found", fadump_region_file)
                return None

        fadump_regions = get_file_content(fadump_region_file)
        if fadump_regions is None:
            return None

        fadump_mem = 0
        for region in fadump_regions.split('\n'):
            self.log.debug("Fadump region(%s)", region)
            region = region.strip()
            try:
                if region.startswith("CPU") or region.startswith("HPTE"):
                    region_size = region[region.find(':') +
                                         1:len(region)].strip().split()[1]
                elif region.startswith("DUMP"):
                    region_list = region.split()
                    if len(region_list) > 6:
                        region_size = region_list[4][:-1]
                    else:
                        region_size = region_list[2]
                else:
                    self.log.warning("Unknown Fadump region(%s)", region)
                    continue
                fadump_mem = fadump_mem + int(region_size, 16)

            except Exception:
                self.log.debug("Unable to parse %s", fadump_region_file)
                return None

        self.log.debug("Fadump mem from (%s): %s bytes", fadump_region_file,
                       fadump_mem)
        return fadump_mem / 1024 / 1024