Skip to contentSkip to conversation

A couple runtime fixes

PATCH In review Andrew Jones 2 participants 4 messages Apr 4, 2020 – Apr 7, 2020 KVM

lore
Share & tools
lore
#0 lore raw

cover A couple runtime fixes

While testing the recent arm pull request I stumbled on to a couple issues with the runtime scripts.

Andrew Jones (2):
run_migration: Implement our own wait
runtime: Always honor the unittests.cfg accel requirement

 scripts/arch-run.bash | 6 +++++-
 scripts/runtime.bash  | 9 ++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 run_migration: Implement our own wait

Bash 5.0 changed 'wait' with no arguments to also wait for all process substitutions. For example, with Bash 4.4 this completes, after waiting for the sleep

(
sleep 1 &
wait
) > >(tee /dev/null)

but with Bash 5.0 it does not. The kvm-unit-tests (overly) complex bash scripts have a 'run_migration ... 2> >(tee /dev/stderr)' where the '2> >(tee /dev/stderr)' comes from 'run_qemu'. Since 'run_migration' calls 'wait' it will never complete with Bash 5.0. Resolve by implementing our own wait; just a loop on job count.

---
 scripts/arch-run.bash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/arch-run.bash +5 -1
index d3ca19d49952..da1a9d7871e5 100644
@@ -156,7 +156,11 @@ run_migration ()
 	echo > ${fifo}
 	wait $incoming_pid
 	ret=$?
-	wait
+
+	while (( $(jobs -r | wc -l) > 0 )); do
+		sleep 0.5
+	done
+
 	return $ret
 }
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH kvm-unit-tests 1/2] run_migration: Implement our own wait

Quoted 28 lines · Andrew Jones

Bash 5.0 changed 'wait' with no arguments to also wait for all process substitutions. For example, with Bash 4.4 this completes, after waiting for the sleep

(
sleep 1 &
wait
) > >(tee /dev/null)

but with Bash 5.0 it does not. The kvm-unit-tests (overly) complex bash scripts have a 'run_migration ... 2> >(tee /dev/stderr)' where the '2> >(tee /dev/stderr)' comes from 'run_qemu'. Since 'run_migration' calls 'wait' it will never complete with Bash 5.0. Resolve by implementing our own wait; just a loop on job count.

---
 scripts/arch-run.bash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/arch-run.bash +0 -0
index d3ca19d49952..da1a9d7871e5 100644
@@ -156,7 +156,11 @@ run_migration ()
 	echo > ${fifo}
 	wait $incoming_pid

scripts/arch-run.bash run_migration () · line 166

Quoted 10 lines
scripts/arch-run.bash +5 -1
 	ret=$?
-	wait
+
+	while (( $(jobs -r | wc -l) > 0 )); do
+		sleep 0.5
+	done
+
 	return $ret
 }
 

Ouch. Queued both, thanks.

Paolo

#3 lore raw

PATCH 2/2 runtime: Always honor the unittests.cfg accel requirement

In reply to Andrew Jones

If the unittests.cfg file specifies an accel parameter then don't let the user override it.

---
 scripts/runtime.bash | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
scripts/runtime.bash +8 -1
index eb6089091e23..8bfe31cb9f66 100644
@@ -77,7 +77,7 @@ function run()
     local opts="$5"
     local arch="$6"
     local check="${CHECK:-$7}"
-    local accel="${ACCEL:-$8}"
+    local accel="$8"
     local timeout="${9:-$TIMEOUT}" # unittests.cfg overrides the default
 
     if [ -z "$testname" ]; then
@@ -103,6 +103,13 @@ function run()
         return 2
     fi
 
+    if [ -n "$accel" ] && [ -n "$ACCEL" ] && [ "$accel" != "$ACCEL" ]; then
+        print_result "SKIP" $testname "" "$accel only, but ACCEL=$ACCEL"
+        return 2
+    elif [ -n "$ACCEL" ]; then
+        accel="$ACCEL"
+    fi
+
     # check a file for a particular value before running a test
     # the check line can contain multiple files to check separated by a space
     # but each check parameter needs to be of the form <path>=<value>
Signature · 1 line
2.25.1