-
Notifications
You must be signed in to change notification settings - Fork 50
libkmod: tools: Introduce 'module alternative' directory (was: module fallback) #261
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
base: master
Are you sure you want to change the base?
Conversation
Can we get a manpage(s) update, on how things are supposed to work? Ideally it will include (either the doc or commit message) some details why the alternative ordering or behaviour isn't warranted. Once that is solid and we're comfortable things won't backfire/respective workflows are supported/etc, we can beat the code and tests in shape. |
Sure, I thought the commit messages and PR description were self explanatory.
|
Hi @evelikov I am re-reading your notification and I am not sure what you mean with |
Hi @evelikov can you please answer my question? I will be happy to add manpage if you tell me what you want to see exactly |
8acb734
to
4c27973
Compare
Added doc and the last two commits show a possible fix to the confusing error messages that come up when the first call to MODULES_DIRECTORY fails but the second to MODULES_ALTERNATIVE_DIRECTORY is successful. |
26041ac
to
3d48c21
Compare
Finished with first pass of fixes (hopefully waiting reviews). |
3d48c21
to
7ac8aa1
Compare
This option allows the user to specify the alternative directory that the kmod tools should look at when MODULE_DIRECTORY is empty. Defaults to /run/modules. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Add a boolean flag at setup time to let the user decide whether kmod should consider the fallback MODULE_ALTERNATIVE_DIRECTORY or not. If this flag is False, MODULE_ALTERNATIVE_DIRECTORY will be ignored. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
With the incoming MODULE_ALTERNATIVE_DIRECTORY double logic where the same core function for each kmod tool will be called twice, once on MODULE_DIRECTORY path and another time on MODULE_ALTERNATIVE_DIRECTORY, we need to somehow catch the error and print it only if both calls on these two directories fail. Otherwise we risk to make kmod very confusing for the user because we might show an error first (MODULE_DIRECTORY missing), and then the fallback (MODULE_ALTERNATIVE_DIRECTORY) successfully does its job leaving command is successful. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
…issing Currently if no module is found in MODULE_DIRECTORY, kmod will just print "Module %s not found", but now that we are adding two search paths, it is worth specifying which is the path that was not found. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_static_nodes into two helpers: one to get the dirname (MODULE_DIRECTORY/$kernel) and another to do the main logic. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
nabled -- can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_modinfo into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Using the macros developed in log.h, catch the error and print it only if both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY call fail. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Now that we have to repeat the same logic twice for MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY, setting LOG priority to FATAL causes modprobe to exit failure, without trying the second path. Therefore increase the log priority to ERROR. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_modprobe into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
…-- can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Using the macros developed in log.h, catch the error and print it only if both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY call fail. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_insmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
… can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Using the macros developed in log.h, catch the error and print it only if both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY call fail. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_lsmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
…can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Using the macros developed in log.h, catch the error and print it only if both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY call fail. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Move code in do_rmmod into two helpers: one to get the dirname ($root/MODULE_DIRECTORY/$kernel) and another to do the main logic. The first helper, get_module_dirname(), is also always called to figure the dirname path and to avoid providing NULL to the kmod_new() API. This is because kmod_new() always defaults to MODULE_DIRECTORY when the dirname path is empty, and won't work when MODULE_ALTERNATIVE_DIRECTORY will be used. This is in preparation to perform the same two steps again for the new MODULE_ALTERNATIVE_DIRECTORY option. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
If nothing is found in MODULE_DIRECTORY, perform the same exact steps but with MODULE_ALTERNATIVE_DIRECTORY. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
…can be squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Using the macros developed in log.h, catch the error and print it only if both MODULE_DIRECTORY and MODULE_ALTERNATIVE_DIRECTORY call fail. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Esplicitly define MODULE_ALTERNATIVE_DIRECTORY in the docs as fallback directory if MODULE_DIRECTORY is missing or the module is not present there. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
squashed Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
7ac8aa1
to
c0bbebf
Compare
Also added the optional build flag I put the compile flag together with my solution for logs in separate commits, that can go squashed afterwards. I am waiting for reviews to see whether these options are useful or not :) |
Hello maintainers, can you please give a look at this PR? I think it's in shape for a first pass :) @lucasdemarchi @evelikov |
1 similar comment
Hello maintainers, can you please give a look at this PR? I think it's in shape for a first pass :) @lucasdemarchi @evelikov |
Hello maintainers, can you please give a look at this PR? I think it's in shape for a first pass :) @lucasdemarchi @evelikov |
Sorry life got in the way, plus I've been sick as a dog the last month or so. In my earlier comment, I requested that the manual pages are updated to summarise all the discussions so far. Basically, how things work and why the order is the way it was proposed. Basically, the information you would expect if in 6 months time you have completely forgotten the topic and are working on systemd, dracut, the kernel. Sometimes it helps, to update a man page and pass it to ^^ developer (friend or colleague) who completely lacks the background and see if they can make sense of it. Some questions from very quickly (literally a few seconds) glancing through the commits:
Overall I am onboard with the idea and would review the patches, once Lucas is happy with how things should work at a high level. |
That's what I did :)
The main change here is that if /lib/modules exists, nothing changes in kmod functionality. If, however, for some reasons it misses, /run/modules is used as search path.
See above, some commits are reused
Because otherwise if the modules are in /run you get something like
which toggle
I can look at that. But when you have time, can you give this PR a more than a few seconds look?
Nice |
This PR is the improvement of #202 opened by @vittyvk .
Below you find a description of the original PR. The main change here is that if
/lib/modules
exists, nothing changes in kmod functionality. If, however, for some reasons it misses,/run/modules
is used as search path.The change itself is pretty easy: call twice the same logic for each tool with a different, customizable path (
MODULE_DIRECTORY
andMODULE_ALTERNATIVE_DIRECTORY
).I did not implement any test yet.
Original PR description: