Skip to content

Commit 8b4a793

Browse files
qat, initcontainer: imporve the logic of config check
check_config function considers only SERVICES_ENABLED variable. Improve the logic of the function so other variables could be also set through the qat.conf file Signed-off-by: Hyeongju Johannes Lee <[email protected]>
1 parent 4b62154 commit 8b4a793

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

demo/qat-init.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,32 @@ SERVICES_ENABLED="NONE"
1212
SERVICES_ENABLED_FOUND="FALSE"
1313

1414
check_config() {
15-
[ -f "conf/qat.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat.conf | grep '\S')
16-
[ -f "conf/qat-$NODE_NAME.conf" ] && SERVICES_ENABLED=$(cut -d= -f 2 conf/qat-$NODE_NAME.conf | grep '\S')
17-
18-
if [ "$SERVICES_ENABLED" != "NONE" ]; then
19-
SERVICES_ENABLED_FOUND="FALSE"
20-
for SERVICE in $SERVICES_LIST
15+
enabled_config="NONE"
16+
[ -f "conf/qat.conf" ] && enabled_config=$(grep "^$1=" conf/qat.conf | cut -d= -f 2 | grep '\S')
17+
[ -f "conf/qat-$NODE_NAME.conf" ] && enabled_config=$(grep "^$1=" conf/qat-"$NODE_NAME".conf | cut -d= -f 2 | grep '\S')
18+
is_config_valid="FALSE"
19+
if [ "$enabled_config" != "NONE" ]; then
20+
for config in $2
2121
do
22-
if [ "$SERVICE" = "$SERVICES_ENABLED" ]; then
23-
SERVICES_ENABLED_FOUND="TRUE"
22+
if [ "$config" = "$enabled_config" ]; then
23+
is_config_valid="TRUE"
2424
break
2525
fi
2626
done
2727
fi
28+
if [ "$is_config_valid" = "TRUE" ]; then
29+
echo "$enabled_config"
30+
else
31+
echo "NONE"
32+
fi
33+
}
34+
35+
is_found() {
36+
if [ "$1" = "NONE" ]; then
37+
echo "FALSE"
38+
else
39+
echo "TRUE"
40+
fi
2841
}
2942

3043
sysfs_config() {
@@ -66,6 +79,7 @@ enable_sriov() {
6679
done
6780
}
6881

69-
check_config
82+
SERVICES_ENABLED=$(check_config "ServicesEnabled" "$SERVICES_LIST")
83+
SERVICES_ENABLED_FOUND=$(is_found "$SERVICES_ENABLED")
7084
sysfs_config
7185
enable_sriov

0 commit comments

Comments
 (0)