Skip to content

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Sep 18, 2025

Improve set/get cmdline to support uefi

What I did

Fix sonic-net/sonic-buildimage#23820
sonic-installer get-fips/set-fips not working on systems in UEFI mode

How I did it

Improve get_linux_cmdline and set_linux_cmdline to support linuxefi

How to verify it

Manually verify.
Pass all test case

Work item tracking
  • Microsoft ADO: 34847974

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the GRUB bootloader support in sonic-installer to handle UEFI systems by adding support for the linuxefi command in addition to the existing linux command. This fixes an issue where sonic-installer get-fips/set-fips commands were not working on UEFI systems.

  • Added support for linuxefi command in cmdline parsing and modification
  • Maintained backward compatibility with legacy linux command
  • Fixed FIPS configuration on UEFI systems

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 96 to 101
if line.startswith('linuxefi '):
cmdline = line[9:].strip()
break
elif line.startswith('linux '):
cmdline = line[6:].strip()
break
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The magic numbers 9 and 6 represent the length of 'linuxefi ' and 'linux ' respectively. Consider extracting these as named constants (e.g., LINUXEFI_PREFIX_LEN = len('linuxefi ')) to improve code readability and maintainability.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is valid comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 112 to 117
if line.startswith('linuxefi '):
new_menuentry = old_menuentry.replace(line, "linuxefi " + cmdline)
break
elif line.startswith('linux '):
new_menuentry = old_menuentry.replace(line, "linux " + cmdline)
break
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

Similar to the get_linux_cmdline method, the hardcoded prefix strings 'linuxefi ' and 'linux ' should be extracted as constants to maintain consistency and reduce duplication across both methods.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is valid comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Updated test to use new temporary host path for EFI.
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 25, 2025

@stepanblyschak , can you review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: sonic-installer get-fips/set-fips not working on systems in UEFI mode
5 participants