Skip to content

Commit

Permalink
Skip kernel parameters configuration for Ubuntu
Browse files Browse the repository at this point in the history
It's enouph to configure ib_core module in /etc/moprobe.d/ for
Ubuntu OS to change RDMA subsystem mode.

Also this commit add OS check into  kargs.sh error because 'grubby'
isn't available in official Ubuntu repositories.

Kernel param configuration support in Ubuntu should be implemented
in a separate commit.

Signed-off-by: Ivan Kolodiazhnyi <[email protected]>
  • Loading branch information
e0ne committed Dec 23, 2024
1 parent d172b52 commit efbafa1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 37 deletions.
79 changes: 42 additions & 37 deletions bindata/scripts/kargs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,54 @@ declare -a kargs=( "$@" )
ret=0
args=$(chroot /host/ cat /proc/cmdline)

if chroot /host/ test -f /run/ostree-booted ; then
for t in "${kargs[@]}";do
if [[ $command == "add" ]];then
if [[ $args != *${t}* ]];then
if chroot /host/ rpm-ostree kargs | grep -vq ${t}; then
chroot /host/ rpm-ostree kargs --append ${t} > /dev/null 2>&1
IS_OS_UBUNTU=true; [[ "$(chroot /host/ grep -i ubuntu /etc/os-release -c)" == "0" ]] && IS_OS_UBUNTU=false

# Kernerl args comfiguration isn't supported for Ubuntu now, so we shouldn't do anything here
if ! ${IS_OS_UBUNTU} ; then
if chroot /host/ test -f /run/ostree-booted ; then
for t in "${kargs[@]}";do
if [[ $command == "add" ]];then
if [[ $args != *${t}* ]];then
if chroot /host/ rpm-ostree kargs | grep -vq ${t}; then
chroot /host/ rpm-ostree kargs --append ${t} > /dev/null 2>&1
fi
let ret++
fi
let ret++
fi
fi
if [[ $command == "remove" ]];then
if [[ $args == *${t}* ]];then
if chroot /host/ rpm-ostree kargs | grep -q ${t}; then
chroot /host/ rpm-ostree kargs --delete ${t} > /dev/null 2>&1
fi
let ret++
fi
fi
done
else
chroot /host/ which grubby > /dev/null 2>&1
# if grubby is not there, let's tell it
if [ $? -ne 0 ]; then
exit 127
fi
for t in "${kargs[@]}";do
if [[ $command == "add" ]];then
if [[ $args != *${t}* ]];then
if chroot /host/ grubby --info=DEFAULT | grep args | grep -vq ${t}; then
chroot /host/ grubby --update-kernel=DEFAULT --args=${t} > /dev/null 2>&1
if [[ $command == "remove" ]];then
if [[ $args == *${t}* ]];then
if chroot /host/ rpm-ostree kargs | grep -q ${t}; then
chroot /host/ rpm-ostree kargs --delete ${t} > /dev/null 2>&1
fi
let ret++
fi
fi
let ret++
done
else
chroot /host/ which grubby > /dev/null 2>&1
# if grubby is not there, let's tell it
if [ $? -ne 0 ]; then
exit 127
fi
fi
if [[ $command == "remove" ]];then
if [[ $args == *${t}* ]];then
if chroot /host/ grubby --info=DEFAULT | grep args | grep -q ${t}; then
chroot /host/ grubby --update-kernel=DEFAULT --remove-args=${t} > /dev/null 2>&1
for t in "${kargs[@]}";do
if [[ $command == "add" ]];then
if [[ $args != *${t}* ]];then
if chroot /host/ grubby --info=DEFAULT | grep args | grep -vq ${t}; then
chroot /host/ grubby --update-kernel=DEFAULT --args=${t} > /dev/null 2>&1
fi
let ret++
fi
let ret++
fi
fi
done
if [[ $command == "remove" ]];then
if [[ $args == *${t}* ]];then
if chroot /host/ grubby --info=DEFAULT | grep args | grep -q ${t}; then
chroot /host/ grubby --update-kernel=DEFAULT --remove-args=${t} > /dev/null 2>&1
fi
let ret++
fi
fi
done
fi
fi

echo $ret
4 changes: 4 additions & 0 deletions test/scripts/kargs_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SUT_SCRIPT="${SCRIPTPATH}/../../bindata/scripts/kargs.sh"


test_RpmOstree_Add_All_Arguments() {
echo "ID=\"rhel\"" > ${FAKE_HOST}/etc/os-release
echo "a b c=d eee=fff" > ${FAKE_HOST}/proc/cmdline
touch ${FAKE_HOST}/run/ostree-booted

Expand All @@ -19,6 +20,7 @@ test_RpmOstree_Add_All_Arguments() {


test_RpmOstree_Add_Only_Missing_Arguments() {
echo "ID=\"rhel\"" > ${FAKE_HOST}/etc/os-release
echo "a b c=d eee=fff K=L" > ${FAKE_HOST}/proc/cmdline
touch ${FAKE_HOST}/run/ostree-booted

Expand All @@ -31,6 +33,7 @@ test_RpmOstree_Add_Only_Missing_Arguments() {
}

test_RpmOstree_Delete_All_Arguments() {
echo "ID=\"rhel\"" > ${FAKE_HOST}/etc/os-release
echo "a b c=d eee=fff X=Y W=Z" > ${FAKE_HOST}/proc/cmdline
touch ${FAKE_HOST}/run/ostree-booted

Expand All @@ -43,6 +46,7 @@ test_RpmOstree_Delete_All_Arguments() {
}

test_RpmOstree_Delete_Only_Exist_Arguments() {
echo "ID=\"rhel\"" > ${FAKE_HOST}/etc/os-release
echo "a b c=d eee=fff X=Y" > ${FAKE_HOST}/proc/cmdline
touch ${FAKE_HOST}/run/ostree-booted

Expand Down

0 comments on commit efbafa1

Please sign in to comment.