-
Notifications
You must be signed in to change notification settings - Fork 171
Add driver configuration support for dracut initrd #2832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add support for specifying kernel drivers to be included or omitted
in the dracut initrd configuration. This extends the existing dracut
configuration capabilities by allowing users to:
- Configure specific drivers through the <dracut> element:
<dracut driver="driver_name"/>
- Control driver inclusion/omission in both system and installation
initrds through:
- add_drivers/omit_drivers in dracut.conf
- --drivers/--omit-drivers command line options
Key changes:
- Add driver attribute to dracut schema definition
- Implement driver handling in BootImageDracut
- Add driver support in DiskBuilder and InstallImageBuilder
- Update XMLState to process driver configurations
- Add comprehensive test coverage for driver handling
Example usage:
<initrd action="add">
<dracut driver="erofs"/>
</initrd>
9f6e4d6 to
3ee3db0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks much for your work. Just one remark of a Kernel class that we should re-use and a question regarding the creation of auto generated data. Thanks much
| def _get_drivers(self) -> List[str]: | ||
| try: | ||
| kernel_version = Command.run([ | ||
| 'chroot', self.boot_root_directory, | ||
| 'uname', '-r' | ||
| ]).output.strip() | ||
| cmd = Command.run( | ||
| [ | ||
| 'chroot', self.boot_root_directory, | ||
| 'cat', f'/lib/modules/{kernel_version}/modules.dep' | ||
| ] | ||
| ) | ||
| drivers = [] | ||
| for line in cmd.output.splitlines(): | ||
| if line: | ||
| driver_path = line.split(':')[0].strip() | ||
| driver_name = os.path.basename(driver_path).split('.ko')[0] | ||
| drivers.append(driver_name) | ||
| return drivers | ||
| except Exception as e: | ||
| log.warning(f"Error reading drivers: {str(e)}") | ||
| return [] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We offer a Kernel class that simplifies retrieving data like the kernel version. Can we make use of this code instead of sort of duplicating the code. e.g.
from kiwi.system.kernel import Kernel
kernel = Kernel(root_dir)
kernel_info = kernel.get_kernel()
print(kernel_info.version)feel free to extend the Kernel interface if need be. Thanks much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now using kernel_info.version to obtain the kernel version. Thank you for suggesting using the Kernel class.
| subclass = None | ||
| superclass = None | ||
| def __init__(self, module=None, uefi=None): | ||
| def __init__(self, module=None, driver=None, uefi=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a stupid question and just to put me right. The xml_parse.py is like the schema/kiwi.rng an auto generated file. So am I correct that you only modified schema/kiwi.rnc and then called make kiwi/schema/kiwi.rng to auto generated the API ? If yes, all is good, if not and you have manually modified xml_parse.py or schema/kiwi.rng then please let it create through the make target. Thanks much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the latest commit, I ran make kiwi/schema/kiwi.rng, but I had to manually adjust the output in kiwi/xml_parse.py to use f-string formatting because generateDS.py tool doesn't generate the output using f-string format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aale24 I can keep this for now but please have in mind that the next schema changes might revert this back to the way how the generatedDS module handles it. Did you had a programmatic way to move from format sequences into f strings ? If yes we should add that to the Makefile as a step after generateDS.
In addition I could not find an issue in the auto generated API with regards to format sequences vs. f-strings. So did you had a specific reason why this change was required ?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schaefi. You're correct that this situation requires some clarification:
- The change to f-strings was initially made in this commit: 28ed67e
- When I ran make
kiwi/schema/kiwi.rng, the generateDS tool reverted the f-strings back to format sequences inkiwi/xml_parse.py. - To maintain consistency with the earlier commit and to avoid introducing unnecessary changes in the PR, I manually adjusted the output in
kiwi/xml_parse.pyback to f-strings after running the make command.
You're right that this manual adjustment isn't ideal, as future schema changes might revert it again. Currently, I don't have a programmatic way to convert format sequences to f-strings automatically but I could create an issue and work on that. Let me know if you want to use the f-string format in kiwi/xml_parse.py
|
Oh and I forgot to mention we need at least some words about the new elements in the documentation. Please find it here:
There is already documentation for the existing elements, just add the new ones as you see fit. Thanks |
|
Thanks for the comments, I will be working on them. |
- Use Kernel class instead of direct commands - Adjust tests to match the new implementation - Add documentation for the new driver functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now, thanks much 👍
Add support for specifying kernel drivers to be included or omitted in the dracut initrd configuration. This extends the existing dracut configuration capabilities by allowing users to:
Configure specific drivers through the element:
Control driver inclusion/omission in both system and installation initrds through:
Key changes:
Example usage:
Partially Fixes #2808