Skip to content

Commit

Permalink
[tdx-guest] Test Enhance: handle kexec stuck and bypass shutdown failure
Browse files Browse the repository at this point in the history
1. handle kexec stuck issue by stop all systemd services before kexec
   kernel switch, as stuck introduced by systemd instead of kernel
2. shutdown TDVM after all kexec tests in kexec test script, to bypass
   potential shutdown failure unexpected in guest_test_executor

[Test Components] tdx-guest
[Test Types] func
[Supported Devices] spr,emr,gnr,srf

Signed-off-by: Hongyu Ning <[email protected]>
  • Loading branch information
hongyuni authored and ysun committed Sep 6, 2024
1 parent 90b9ee0 commit de35c97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 0 additions & 6 deletions BM/tdx-guest/tdx.guest_test_executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,6 @@ case "$TESTCASE" in
guest_test_prepare tdx_kexec_test.sh
guest_test_entry tdx_kexec_test.sh "-v $VCPU -m $MEM -o no -k $KEXEC_CNT" || \
die "Failed on $TESTCASE tdx_kexec_test.sh -v $VCPU -m $MEM -o no -k $KEXEC_CNT"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
# continous TD KEXEC test group with $VCPU VCPU $MEM GB mem and mem drain
TD_KEXEC_MEM_DRAIN_"$VCPU"C_"$MEM"G_CYCLE_2 | TD_KEXEC_MEM_DRAIN_"$VCPU"C_"$MEM"G_CYCLE_1)
Expand All @@ -416,9 +413,6 @@ case "$TESTCASE" in
guest_test_prepare tdx_kexec_test.sh
guest_test_entry tdx_kexec_test.sh "-v $VCPU -m $MEM -o yes -k $KEXEC_CNT" || \
die "Failed on $TESTCASE tdx_kexec_test.sh -v $VCPU -m $MEM -o yes -k $KEXEC_CNT"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
:)
test_print_err "Must specify the test scenario option by [-t]"
Expand Down
8 changes: 6 additions & 2 deletions BM/tdx-guest/tdx_kexec_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ memory_drain() {

# function to load kexec target kenrel image and trigger kexec switch to target kernel
kexec_load_switch() {
# stop systemd to avoid unexpected stuck
systemctl stop systemd*
# load kexec target kernel image and initrd, reuse kernel cmdline
if ! kexec -d -l "/boot/vmlinuz-$(uname -r)" --initrd="/boot/initramfs-$(uname -r).img" --reuse-cmdline; then
die "failed to load kexec target kernel image, test failed"
else
test_print_trc "kexec target kernel image loaded"
fi
sleep 45
sleep 5
# trigger kexec switch to target kernel
test_print_trc "kexec switch to target kernel triggered"
kexec -d -e &
Expand Down Expand Up @@ -162,11 +164,13 @@ if [[ "$KEXEC_SSH" != "yes" ]]; then
fi
elif [[ "$KEXEC_CNT" -eq 0 ]]; then
test_print_trc "skip kexec load and switch in final test loop"
test_print_trc "TDVM to shutdown after all kexec test completed"
shutdown now || die "failed to shutdown TDVM in final test loop"
else
die "unsupported kexec test cycle count: $KEXEC_CNT"
fi
else # $KEXEC_SSH == "yes", run kexec via ssh standalone to bypass abnormal kexec stuck
test_print_trc "run kexec_load_switch via ssh standalone"
sleep 45
sleep 5
kexec_load_switch || die "failed on kexec_load_switch ssh standalone"
fi

0 comments on commit de35c97

Please sign in to comment.