Skip to content

install: Fix --console flag on s390x#1732

Open
nikita-dubrovskii wants to merge 1 commit intocoreos:mainfrom
nikita-dubrovskii:issue-1171
Open

install: Fix --console flag on s390x#1732
nikita-dubrovskii wants to merge 1 commit intocoreos:mainfrom
nikita-dubrovskii:issue-1171

Conversation

@nikita-dubrovskii
Copy link
Contributor

On s390x, the installer was attempting to modify GRUB config that doesn't exist. This caused installations with --console to fail. Fix by skipping write_console() on s390x and instead applying console kernel arguments to BLS entries."

Issue: #1171

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue where using the --console flag on s390x would cause the installation to fail. The fix correctly skips modifying the non-existent GRUB configuration on s390x and instead applies the console kernel arguments to the BLS entries. The changes look correct and effectively address the issue. I've added one suggestion to refactor the kernel argument modifications to be more efficient by combining multiple file I/O operations into one.

Comment on lines +465 to +470
visit_bls_entry_options(mount.mountpoint(), |orig_options: &str| {
KargsEditor::new()
.append_if_missing(console_kargs.as_slice())
.maybe_apply_to(orig_options)
})
.context("appending console kargs")?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This introduces a second call to visit_bls_entry_options, which involves reading from and writing to the BLS entry file. The call for append-karg and delete-karg on lines 448-454 and this new call for console kargs could be combined into a single operation to improve efficiency and maintainability.

You could build a KargsEditor instance and apply all modifications in one go. Here's a suggested refactoring for lines 441-471:

        let mut kargs_editor = KargsEditor::new();

        if !config.append_karg.is_empty() || !config.delete_karg.is_empty() {
            eprintln!("Modifying kernel arguments");

            // On s390x there is no GRUB config, so skip this check to avoid a user warning.
            #[cfg(not(target_arch = "s390x"))]
            Console::maybe_warn_on_kargs(&config.append_karg, "--append-karg", "--console");

            kargs_editor
                .append(config.append_karg.as_slice())
                .delete(config.delete_karg.as_slice());
        }

        #[cfg(target_arch = "s390x")]
        {
            // Since there's no GRUB config, set console kargs by updating the BLS config
            if !config.console.is_empty() {
                eprintln!("Adding console kernel arguments");
                let console_kargs = config.console.iter().map(|c| c.karg()).collect::<Vec<_>>();
                kargs_editor.append_if_missing(console_kargs.as_slice());
            }
        }

        if kargs_editor != KargsEditor::default() {
            visit_bls_entry_options(mount.mountpoint(), |orig_options: &str| {
                kargs_editor.maybe_apply_to(orig_options)
            })
            .context("modifying kernel arguments")?;
        }

This would consolidate all kernel argument modifications before the s390x::zipl call.

@nikita-dubrovskii
Copy link
Contributor Author

Checked on s390x, ttyS123 was successfully added:

$coreos-installer install --console ttyS123 /dev/vdb
Downloading Fedora CoreOS stable s390x metal image (raw.xz) and signature
> Read disk 582.4 MiB/582.4 MiB (100%)   
gpg: Signature made Sat Feb 28 07:39:40 2026 UTC
gpg:                using RSA key C6E7F081CF80E13146676E88829B606631645531
gpg: Good signature from "Fedora (43) <fedora-43-primary@fedoraproject.org>" [ultimate]
Adding console kernel arguments
Looking for components in '/lib/s390-tools'
Secure boot support: no
Target device information
  Device..........................: fd:10
  Partition.......................: fd:13
  Device name.....................: vdb
  Device driver name..............: virtblk
  Type............................: disk partition
  Disk layout.....................: SCSI disk layout
  Geometry - start................: 2048
  File system block size..........: 1024
  Physical block size.............: 512
  Device size in physical blocks..: 786432
Building bootmap in '/tmp/coreos-installer-JRNSyV'
Adding IPL section
  initial ramdisk...: /tmp/coreos-installer-JRNSyV/boot/ostree/fedora-coreos-52a6950d57dd4628986758f0492289b6f56082f9c95318e473506f9ec7f4c051/initramfs-6.18.10-200.fc43.s390x.img
  kernel image......: /tmp/coreos-installer-JRNSyV/boot/ostree/fedora-coreos-52a6950d57dd4628986758f0492289b6f56082f9c95318e473506f9ec7f4c051/vmlinuz-6.18.10-200.fc43.s390x
  kernel parmline...: 'rw mitigations=auto,nosmt ostree=/ostree/boot.1/fedora-coreos/52a6950d57dd4628986758f0492289b6f56082f9c95318e473506f9ec7f4c051/0 ignition.platform.id=metal console=ttyS123,9600n8 ignition.firstboot'
  component address:
    heap area.......: 0x00002000-0x00005fff
    stack area......: 0x0000f000-0x0000ffff
    internal loader.: 0x0000a000-0x0000dfff
    parameters......: 0x00009000-0x000091ff
    kernel image....: 0x00010000-0x00ea0fff
    parmline........: 0x00ea1000-0x00ea11ff
    initial ramdisk.: 0x00ec0000-0x04d33fff
    environment blk.: 0x00eb1000-0x00eb13ff
zIPL environment block content:
Preparing boot device for LD-IPL: vdb (0000).
Installing on base disk: vdb.
Detected SCSI PCBIOS disk layout.
Writing SCSI master boot record.
Syncing disks...
Done.
Updating re-IPL device
Re-IPL type: ccw
Device:      0.0.0001
Loadparm:    ""
clear:       0

Note: detected other devices with a filesystem labeled `boot`:
  - /dev/vdc3
The installed OS may not work correctly if there are multiple boot filesystems.
Before rebooting, investigate whether these filesystems are needed and consider
wiping them with `wipefs -a`.

Install complete.

On s390x, the installer was attempting to modify GRUB config that
doesn't exist. This caused installations with --console to fail.
Fix by skipping write_console() on s390x and instead applying console
kernel arguments to BLS entries."

Issue: coreos#1171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant