[kvm-unit-tests PATCH v3 12/16] scripts: Detect kvmtool failure in premature_failure()
Alexandru Elisei
alexandru.elisei at arm.com
Thu May 8 01:12:52 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.
Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
---
scripts/runtime.bash | 8 +++-----
scripts/vmm.bash | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 86d8a2cd8528..01ec8eae2bba 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -1,3 +1,5 @@
+source scripts/vmm.bash
+
: "${RUNTIME_arch_run?}"
: "${MAX_SMP:=$(getconf _NPROCESSORS_ONLN)}"
: "${TIMEOUT:=90s}"
@@ -19,11 +21,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_opts[$TARGET:parse_premature_failure]} "$log" || return 1
RUNTIME_log_stderr <<< "$log"
diff --git a/scripts/vmm.bash b/scripts/vmm.bash
index d24a4c4b8713..a1d50ed51981 100644
--- a/scripts/vmm.bash
+++ b/scripts/vmm.bash
@@ -93,6 +93,27 @@ kvmtool_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_parse_premature_failure()
+{
+ local log="$@"
+
+ echo "$log" | grep "Fatal: Unable to open kernel _NO_FILE_4Uhere_" &&
+ return 1
+ return 0
+}
+
declare -A vmm_opts=(
[qemu:nr_cpus]='-smp'
[qemu:kernel]='-kernel'
@@ -100,6 +121,7 @@ declare -A vmm_opts=(
[qemu:initrd]='-initrd'
[qemu:default_opts]=''
[qemu:fixup_return_code]=qemu_fixup_return_code
+ [qemu:parse_premature_failure]=qemu_parse_premature_failure
[kvmtool:nr_cpus]='--cpus'
[kvmtool:kernel]='--kernel'
@@ -107,6 +129,7 @@ declare -A vmm_opts=(
[kvmtool:initrd]='--initrd'
[kvmtool:default_opts]="$KVMTOOL_DEFAULT_OPTS"
[kvmtool:fixup_return_code]=kvmtool_fixup_return_code
+ [kvmtool:parse_premature_failure]=kvmtool_parse_premature_failure
)
function check_vmm_supported()
--
2.49.0
More information about the Linuxppc-dev
mailing list