Exemplo n.º 1
0
def main():
    """
    DistMigration load new kernel for kexec reboot

    Loads the new kernel/initrd after migration for system reboot
    """
    root_path = Defaults.get_system_root_path()

    target_kernel = os.sep.join([root_path, Defaults.get_target_kernel()])
    target_initrd = os.sep.join([root_path, Defaults.get_target_initrd()])
    kexec_boot_data = '/var/tmp/kexec'
    Path.create(kexec_boot_data)
    shutil.copy(target_initrd, kexec_boot_data)
    try:
        log.info('Running kernel load service')
        log.info('Loading the target kernel')
        Command.run([
            'kexec', '--load', target_kernel, '--initrd',
            os.sep.join([kexec_boot_data,
                         os.path.basename(target_initrd)]), '--command-line',
            _get_cmdline(os.path.basename(target_kernel))
        ])
    except Exception as issue:
        log.error('Kernel load service raised exception: {0}', format(issue))
        raise DistMigrationKernelRebootException(
            'Failed to load kernel/initrd into memory: {0}'.format(issue))
Exemplo n.º 2
0
def main():
    """
    DistMigration load new kernel for kexec reboot

    Loads the new kernel/initrd after migration for system reboot
    """
    Logger.setup()
    log = logging.getLogger(Defaults.get_migration_log_name())
    if not MigrationConfig().is_soft_reboot_requested():
        log.info('skipping kexec --load (hard reboot requested)')
        return

    root_path = Defaults.get_system_root_path()

    target_kernel = os.sep.join([root_path, Defaults.get_target_kernel()])
    target_initrd = os.sep.join([root_path, Defaults.get_target_initrd()])
    kexec_boot_data = '/var/tmp/kexec'
    Path.create(kexec_boot_data)
    shutil.copy(target_initrd, kexec_boot_data)
    try:
        log.info('Running kernel load service')
        log.info('Loading the target kernel')
        Command.run([
            'kexec', '--load', target_kernel, '--initrd',
            os.sep.join([kexec_boot_data,
                         os.path.basename(target_initrd)]),
            '--kexec-file-syscall', '--command-line',
            _get_cmdline(os.path.basename(target_kernel))
        ])
    except Exception as issue:
        log.error('Kernel load service raised exception: {0}'.format(issue))
        raise DistMigrationKernelRebootException(
            'Failed to load kernel/initrd into memory: {0}'.format(issue))