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

[warm/fast-reboot] Fix kexec portion to support platforms based on De… #1966

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
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
29 changes: 24 additions & 5 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SSD_FW_UPDATE="ssd-fw-upgrade"
TAG_LATEST=yes
DETACH=no
LOG_PATH="/var/log/${REBOOT_TYPE}.txt"
UIMAGE_HDR_SIZE=64

# Require 100M available on the hard drive for warm reboot temp files,
# Size is in 1K blocks:
Expand Down Expand Up @@ -327,15 +328,33 @@ function setup_reboot_variables()
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
BOOT_OPTIONS="$(cat "$IMAGE_PATH/kernel-cmdline" | tr '\n' ' ') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
fi
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
elif grep -q onie_platform= /host/machine.conf; then
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
if [ -r /host/grub/grub.cfg ]; then
KERNEL_OPTIONS=$(cat /host/grub/grub.cfg | sed "/$NEXT_SONIC_IMAGE'/,/}/"'!'"g" | grep linux)
KERNEL_IMAGE="/host$(echo $KERNEL_OPTIONS | cut -d ' ' -f 2)"
BOOT_OPTIONS="$(echo $KERNEL_OPTIONS | sed -e 's/\s*linux\s*/BOOT_IMAGE=/') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
# Handle architectures supporting Device Tree
elif [ -f /sys/firmware/devicetree/base/chosen/bootargs ]; then
KERNEL_IMAGE="$(ls $IMAGE_PATH/boot/vmlinuz-*)"
BOOT_OPTIONS="$(cat /sys/firmware/devicetree/base/chosen/bootargs | sed 's/.$//') SONIC_BOOT_TYPE=${BOOT_TYPE_ARG}"
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')

# If initrd is a U-Boot uImage, remove the uImage header
if file ${INITRD} | grep -q uImage; then
INITRD_RAW=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd-raw.img/g')
tail -c+$((${UIMAGE_HDR_SIZE}+1)) < ${INITRD} > ${INITRD_RAW}
INITRD=${INITRD_RAW}
fi
else
error "Unknown ONIE platform bootloader. ${REBOOT_TYPE} is not supported."
exit "${EXIT_NOT_SUPPORTED}"
fi
else
error "Unknown bootloader. ${REBOOT_TYPE} is not supported."
exit "${EXIT_NOT_SUPPORTED}"
fi
INITRD=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd.img/g')
}

function check_docker_exec()
Expand Down Expand Up @@ -393,7 +412,7 @@ function reboot_pre_check()
error "Failed to verify next image. Exit code: $INSTALLER_VERIFY_RC"
exit ${EXIT_SONIC_INSTALLER_VERIFY_REBOOT}
fi

# Make sure ASIC configuration has not changed between images
ASIC_CONFIG_CHECK_SCRIPT="/usr/local/bin/asic_config_check"
ASIC_CONFIG_CHECK_SUCCESS=0
Expand Down
3 changes: 2 additions & 1 deletion scripts/soft-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ REBOOT_TIME=$(date)
REBOOT_METHOD="/sbin/kexec -e"
LOG_SSD_HEALTH="/usr/local/bin/log_ssd_health"
WATCHDOG_UTIL="/usr/local/bin/watchdogutil"
UIMAGE_HDR_SIZE=64

EXIT_SUCCESS=0
EXIT_FAILURE=1
Expand Down Expand Up @@ -133,7 +134,7 @@ function setup_reboot_variables()
# If initrd is a U-Boot uImage, remove the uImage header
if file ${INITRD} | grep -q uImage; then
INITRD_RAW=$(echo $KERNEL_IMAGE | sed 's/vmlinuz/initrd-raw.img/g')
tail -c+65 < ${INITRD} > ${INITRD_RAW}
tail -c+$((${UIMAGE_HDR_SIZE}+1)) < ${INITRD} > ${INITRD_RAW}
INITRD=${INITRD_RAW}
fi
else
Expand Down