[PATCH] selftests/liveupdate: Preserve VM workspaces with run-vmtests.sh -k

Mukesh Pilaniya mpilaniy at redhat.com
Mon Nov 2 07:21:51 PST 2026


Hi George,

On 29/10/26 2:35 pm, George Guo wrote:
> From: George Guo <guodongtai at kylinos.cn>
> 
> run-vmtests.sh -k keeps the test output logs, but vmtest.sh still
> removes its workspace and qemu.serial, losing the guest output needed
> to debug failures.
> 
> Forward -k to vmtest.sh when keeping logs and update the help texts to
> match.
> 
> Signed-off-by: George Guo <guodongtai at kylinos.cn>
> ---
>  tools/testing/selftests/liveupdate/run-vmtests.sh | 7 +++++--
>  tools/testing/selftests/liveupdate/vmtest.sh      | 2 +-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/liveupdate/run-vmtests.sh b/tools/testing/selftests/liveupdate/run-vmtests.sh
> index d656ce58c5a7..6f592aec0f85 100755
> --- a/tools/testing/selftests/liveupdate/run-vmtests.sh
> +++ b/tools/testing/selftests/liveupdate/run-vmtests.sh
> @@ -26,7 +26,7 @@ function usage() {
>  	cat <<EOF
>  $0 [-k] [-o output_dir] [-h]
>  Options:
> -	-k)	keep logs
> +	-k)	keep logs and VM workspaces, including guest serial logs
>  	-o)	specify output directory
>  	-h)	display this help
>  EOF
> @@ -48,6 +48,8 @@ function fail() {
>  }
>  
>  function main() {
> +	local -a vmtest_args=()
> +
>  	while getopts 'hko:' opt; do
>  		case $opt in
>  		k) keep_logs=1 ;;
> @@ -59,6 +61,7 @@ function main() {
>  	done
>  
>  	if [ -n "$keep_logs" ]; then
> +		vmtest_args+=(-k)
>  		if [ -z "$output_dir" ]; then
>  			output_dir="$SCRIPT_DIR/results_$(date +%Y%m%d_%H%M%S)"
>  		fi;
> @@ -74,7 +77,7 @@ function main() {
>  
>  			printf "  -> %-8s %-24s ... " "$arch" "$test_name"
>  
> -			"$TEST_RUNNER" -t "$arch" -T "$test_name" &> "$log"
> +			"$TEST_RUNNER" "${vmtest_args[@]}" -t "$arch" -T "$test_name" &> "$log"
>  			exit_code=$?
>  
>  			case $exit_code in
the "4) skip;;" branch in run-vmtests.sh can never be hit.

vmtest.sh's skip() exits with $KSFT_SKIP, but the EXIT trap runs
cleanup(),which calls ktap_finished(), and that exits with $KSFT_PASS
when the counts add up to the plan. So "./vmtest.sh -k -t bogus" prints
"ok 1 ... # SKIP" and still exits 0 (and leaves an empty /tmp/luo-test.*
with -k).

That's a pre-existing bug, not caused by forwarding -k, so it may
require a separate fix that keeps the exit status in cleanup()?
Something like saving $? at the top and exiting with it, calling
ktap_finished() only when it's 0. kho/vmtest.sh has the same pattern, so
it probably wants the same fix.

> diff --git a/tools/testing/selftests/liveupdate/vmtest.sh b/tools/testing/selftests/liveupdate/vmtest.sh
> index 69beda6c961d..bd7032c4b122 100755
> --- a/tools/testing/selftests/liveupdate/vmtest.sh
> +++ b/tools/testing/selftests/liveupdate/vmtest.sh
> @@ -40,7 +40,7 @@ Options:
>  	-t)	run test for target_arch (aarch64, x86_64)
>  	-T)	test name to run (default: luo_kexec_simple)
>  	-w)	custom workspace directory (default: creates temp dir)
> -	-k)	keep workspace directory after successful test
> +	-k)	keep workspace directory
>  	-h)	display this help
>  EOF
>  }
> 
> base-commit: 9a6a70aefe77f6fb9ff2b3037dcf87f6dff65c8c

-- 
Regards,
Mukesh Pilaniya




More information about the kexec mailing list