Skip to content
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

[202205][Arista] Fix cmdline generation during warm-reboot from 201811/201911 #12371

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fi

mountpoint_for_file() {
local file="$1"
df "$file" | tail -1 | tr -s " " | cut -d ' ' -f6
df "$file" 2> /dev/null | tail -1 | tr -s " " | cut -d ' ' -f6
}

# extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
Expand Down Expand Up @@ -695,27 +695,40 @@ write_default_cmdline() {
cmdline_clear

if $in_aboot; then
# generate the default kernel parameters for the platform
# Generate the default kernel parameters for the platform
cat /etc/cmdline | sed "/^\(${bootconfigvars// /\|}\|crashkernel\|loglevel\|ignore_loglevel\)\(\$\|=\)/d;/^\$/d" | cmdline_append
elif grep -q "$delimiter" /proc/cmdline; then
# we are on a recent sonic image using delimiter. extracting the part of the
elif grep -q "$delimiter" /proc/cmdline && ! grep -Eq "varlog_size=.* $delimiter" /proc/cmdline; then
# We are on a recent sonic image using delimiter. extracting the part of the
# cmdline coming from aboot is trivial.
# The 2nd part of the condition ensures that the append bug is not present.
# When it is it should go through the last case of this if/else block to
# regenerate the aboot cmdline
cat /proc/cmdline | sed -E "s/^(.*) $delimiter .*$/\1/" | tr ' ' '\n' | cmdline_append
else
# we are either on SONiC or EOS and the commandline doesn't have a delimiter
# for the Aboot part. Take an educated guess at a right delimiter.
# Subject to breakage if EOS or SONiC cmdline change.
elif grep -q "SWI=" /proc/cmdline; then
# We are in EOS and the cmdline doesn't have a delimiter for the aboot part
cat /proc/cmdline | sed -E 's/^(.*) rw .*$/\1/' | tr ' ' '\n' | cmdline_append
else
# We are in SONiC and the cmdline doesn't have a delimiter for the aboot part.
# sid= should most of the time be the last parameter provided by Aboot
# Alternatively we are in SONiC and the cmdline-aboot-end delimiter was
# added after image specific parameters due to a BUG which is solved by the
# following statement.
cat /proc/cmdline | sed -E 's/^(.* sid=[^ ]+).*$/\1/' | tr ' ' '\n' | cmdline_append
fi

cmdline_add "$delimiter"
}

write_cmdline() {
# use extra parameters from kernel-params hook if the file exists
if [ -f "$target_path/$kernel_params" ] && ! $secureboot; then
info "Loading extra kernel parameters from $kernel_params"
cat "$target_path/$kernel_params" | cmdline_append
if [ -f "$target_path/$kernel_params" ]; then
if $secureboot && $debug; then
warn "Unsafe: Loading extra kernel parameters from $kernel_params"
cat "$target_path/$kernel_params" | cmdline_append
elif ! $secureboot; then
info "Loading extra kernel parameters from $kernel_params"
cat "$target_path/$kernel_params" | cmdline_append
fi
fi

# FIXME: sonic sometimes adds extra kernel parameters from user space
Expand Down Expand Up @@ -801,12 +814,12 @@ regular_install() {

mkdir -p $image_path

info "Generating boot-config, machine.conf and cmdline"
write_regular_configs "$image_path"

info "Installing image under $image_path"
extract_image

info "Generating boot-config, machine.conf and cmdline"
write_regular_configs "$image_path"

run_hooks post-install
}

Expand Down