Skip to content

Conversation

@jeckersb
Copy link
Collaborator

See individual commits, this is mostly stuff to prepare for bootc_kargs to switch over to using kernel_cmdline for all of its parsing.

This is an obvious thing one might want to do.  Ensures we can make an
owned Cmdline directly from an owned String.

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
In some cases it will be important to differentiate whether we added a
net-new parameter vs. modifying an existing parameter.

Motivated by trying to update bootc_kargs to use kernel_cmdline.  We
want to parse the booted kargs, and then merge with any args defined
in kargs.d.  But it should error if a value in kargs.d already exists
in the booted system with a different value.  The previous API did not
provide enough visibility to make this determiniation.

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
This makes it ergonomic to take two `Cmdline`s and update one by
appending the parameters in the other.

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Add a new `add` method to both `bytes::Cmdline` and `utf8::Cmdline`
that appends parameters without modifying existing ones. Unlike
`add_or_modify`, this method preserves duplicate keys with different
values (e.g., multiple `console=` parameters), which is valid for
certain kernel parameters.

The method returns `Action::Added` when a new parameter is appended,
and `Action::Existed` when the exact parameter already exists.

Assisted-by: Claude Code (Sonnet 4.5)
Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Implement Deref / AsRef / Clone in a few places where it makes sense.

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
@bootc-bot bootc-bot bot requested a review from gursewak1997 October 31, 2025 20:44
Copy link
Contributor

@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 introduces several enhancements to the kernel_cmdline crate, including a new add method, Extend and IntoIterator implementations for Cmdline, and changing add_or_modify to return a more descriptive Action enum. The changes are well-tested and improve the usability and functionality of the crate. My main feedback is a suggestion to improve the performance of the Extend implementation, which could be important for the new use cases this PR is preparing for.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Looks sane to me

Action::Added
));
let mut iter = kargs.iter();
assert_eq!(iter.next(), Some(param("console=tty0")));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shockingly it looks like we don't (directly) use itertools anywhere in bootc right now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep totally fine, we can do that kind of stuff as async followup

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Signed-off-by: John Eckersberg <jeckersb@redhat.com>
@jeckersb jeckersb enabled auto-merge (rebase) November 3, 2025 18:42
@jeckersb jeckersb merged commit 27b6189 into bootc-dev:main Nov 3, 2025
37 checks passed
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.

2 participants