[kvm-unit-tests PATCH v4 09/13] scripts: Detect kvmtool failure in premature_failure()
Alexandru Elisei
alexandru.elisei at arm.com
Thu Jun 26 01:48:09 AEST 2025
kvm-unit-tests assumes that if the VMM is able to get to where it tries to
load the kernel, then the VMM and the configuration parameters will also
work for running the test. All of this is done in premature_failure().
Teach premature_failure() about the kvmtool's error message when it fails
to load the dummy kernel.
Reviewed-by: Andrew Jones <andrew.jones at linux.dev>
Reviewed-by: Shaoqin Huang <shahuang at redhat.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
---
Changes v3->v4:
* Use vmm_parse_premature_failure() in
scripts/runtime.bash::premature_failure().
* Do not source scripts/vmm.bash in scripts/runtime.bash to avoid errors in
the standalone tests.
scripts/mkstandalone.sh | 1 +
scripts/runtime.bash | 6 +-----
scripts/vmm.bash | 28 ++++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 9c5768563757..ebf425564af5 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -81,6 +81,7 @@ generate_test ()
echo "RUNTIME_log_stdout () { cat >&\$stdout; }"
echo "RUNTIME_log_stderr () { cat >&2; }"
+ cat scripts/vmm.bash
cat scripts/runtime.bash
echo "run ${args[*]}"
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 86d8a2cd8528..5839ca5ca665 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -19,11 +19,7 @@ premature_failure()
log="$(eval "$(get_cmdline _NO_FILE_4Uhere_)" 2>&1)"
- echo "$log" | grep "_NO_FILE_4Uhere_" |
- grep -q -e "[Cc]ould not \(load\|open\) kernel" \
- -e "error loading" \
- -e "failed to load" &&
- return 1
+ vmm_parse_premature_failure "$log" || return 1
RUNTIME_log_stderr <<< "$log"
diff --git a/scripts/vmm.bash b/scripts/vmm.bash
index 368690d62473..44954a711cad 100644
--- a/scripts/vmm.bash
+++ b/scripts/vmm.bash
@@ -79,6 +79,18 @@ function qemu_fixup_return_code()
echo $ret
}
+function qemu_parse_premature_failure()
+{
+ local log=$*
+
+ echo "$log" | grep "_NO_FILE_4Uhere_" |
+ grep -q -e "[Cc]ould not \(load\|open\) kernel" \
+ -e "error loading" \
+ -e "failed to load" &&
+ return 1
+ return 0
+}
+
function kvmtool_fixup_return_code()
{
local ret=$1
@@ -91,18 +103,29 @@ function kvmtool_fixup_return_code()
echo $ret
}
+function kvmtool_parse_premature_failure()
+{
+ local log=$*
+
+ echo "$log" | grep "Fatal: Unable to open kernel _NO_FILE_4Uhere_" &&
+ return 1
+ return 0
+}
+
declare -A vmm_optname=(
[qemu,args]='-append'
[qemu,default_opts]=''
[qemu,fixup_return_code]=qemu_fixup_return_code
[qemu,initrd]='-initrd'
[qemu,nr_cpus]='-smp'
+ [qemu,parse_premature_failure]=qemu_parse_premature_failure
[kvmtool,args]='--params'
[kvmtool,default_opts]="$KVMTOOL_DEFAULT_OPTS"
[kvmtool,fixup_return_code]=kvmtool_fixup_return_code
[kvmtool,initrd]='--initrd'
[kvmtool,nr_cpus]='--cpus'
+ [kvmtool,parse_premature_failure]=kvmtool_parse_premature_failure
)
function vmm_optname_args()
@@ -130,6 +153,11 @@ function vmm_optname_nr_cpus()
echo ${vmm_optname[$(vmm_get_target),nr_cpus]}
}
+function vmm_parse_premature_failure()
+{
+ ${vmm_optname[$(vmm_get_target),parse_premature_failure]} "$@"
+}
+
function vmm_get_target()
{
if [[ -z "$TARGET" ]]; then
--
2.50.0
More information about the Linuxppc-dev
mailing list