Thanks: Eric Blake for the suggestion here:
https://www.redhat.com/archives/libguestfs/2018-September/msg00069.html
---
tests/functions.sh.in | 25 +++++++++++++++++++++++++
tests/test-blocksize.sh | 9 ++-------
tests/test-cache.sh | 9 ++-------
tests/test-cow.sh | 9 ++-------
tests/test-data-7E.sh | 9 ++-------
tests/test-data-base64.sh | 9 ++-------
tests/test-data-raw.sh | 9 ++-------
tests/test-fua.sh | 9 ++-------
tests/test-log.sh | 9 ++-------
tests/test-memory-largest-for-qemu.sh | 9 ++-------
tests/test-memory-largest.sh | 9 ++-------
tests/test-nozero.sh | 9 ++-------
tests/test-offset2.sh | 9 ++-------
tests/test-parallel-file.sh | 4 +++-
tests/test-parallel-nbd.sh | 4 +++-
tests/test-pattern-largest-for-qemu.sh | 9 ++-------
tests/test-pattern-largest.sh | 9 ++-------
tests/test-pattern.sh | 9 ++-------
tests/test-single.sh | 10 ++--------
tests/test-tls-psk.sh | 10 ++--------
tests/test-tls.sh | 10 ++--------
tests/test-truncate1.sh | 9 ++-------
tests/test-truncate2.sh | 9 ++-------
tests/test-zero.sh | 14 ++------------
24 files changed, 73 insertions(+), 157 deletions(-)
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 62fdfe5..42e3925 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -32,6 +32,31 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+# cleanup_fn f [args]
+#
+# A generic trap handling function. This runs the function f + args
+# when the script exits for any reason.
+declare -a _cleanup_hook
+cleanup_fn ()
+{
+ _cleanup_hook[${#_cleanup_hook[@]}]="$@"
+}
+
+_run_cleanup_hooks ()
+{
+ status=$?
+ set +e
+ trap '' INT QUIT TERM EXIT ERR
+ echo $0: run cleanup hooks: exit code $status
+
+ for (( i = 0; i < ${#_cleanup_hook[@]}; ++i )); do
+ ${_cleanup_hook[i]}
+ done
+
+ exit $status
+}
+trap _run_cleanup_hooks INT QUIT TERM EXIT ERR
+
# foreach_plugin f
#
# For each plugin that was built, call test function f with the plugin
diff --git a/tests/test-blocksize.sh b/tests/test-blocksize.sh
index cb9b09f..21b55b9 100755
--- a/tests/test-blocksize.sh
+++ b/tests/test-blocksize.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
files="blocksize1.img blocksize1.log blocksize1.sock blocksize1.pid
@@ -54,10 +55,6 @@ pid1= pid2=
# Kill any nbdkit processes on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
test "$pid1" && kill $pid1
test "$pid2" && kill $pid2
# For easier debugging, dump the final log files before removing them.
@@ -66,10 +63,8 @@ cleanup ()
echo "Log 2 file contents:"
cat blocksize2.log || :
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Run two parallel nbdkit; to compare the logs and see what changes.
nbdkit -P blocksize1.pid -U blocksize1.sock \
diff --git a/tests/test-cache.sh b/tests/test-cache.sh
index 215bab1..495469d 100755
--- a/tests/test-cache.sh
+++ b/tests/test-cache.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
@@ -60,16 +61,10 @@ pid="$(cat cache.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Open the overlay and perform some operations.
guestfish --format=raw -a "nbd://?socket=$PWD/cache.sock"
<<'EOF'
diff --git a/tests/test-cow.sh b/tests/test-cow.sh
index f9b0649..b5c8f63 100755
--- a/tests/test-cow.sh
+++ b/tests/test-cow.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
@@ -61,16 +62,10 @@ pid="$(cat cow.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Write some data into the overlay.
guestfish --format=raw -a "nbd://?socket=$PWD/cow.sock" -m /dev/sda1
<<EOF
diff --git a/tests/test-data-7E.sh b/tests/test-data-7E.sh
index 8327511..adccd86 100755
--- a/tests/test-data-7E.sh
+++ b/tests/test-data-7E.sh
@@ -34,6 +34,7 @@
# Test the data plugin creating a 7 EB partitioned disk, and
# the partition filter on top.
+source ./functions.sh
set -e
set -x
@@ -104,16 +105,10 @@ pid="$(cat data-7E.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Since we're reading the empty first partition, any read returns zeroes.
qemu-io -r -f raw 'nbd+unix://?socket=data-7E.sock' \
diff --git a/tests/test-data-base64.sh b/tests/test-data-base64.sh
index 6ff324b..72cf743 100755
--- a/tests/test-data-base64.sh
+++ b/tests/test-data-base64.sh
@@ -33,6 +33,7 @@
# Test the data plugin with base64= parameter.
+source ./functions.sh
set -e
set -x
@@ -72,16 +73,10 @@ pid="$(cat data-base64.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=data-base64.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > data-base64.out
diff --git a/tests/test-data-raw.sh b/tests/test-data-raw.sh
index c6652b7..00d4fb1 100755
--- a/tests/test-data-raw.sh
+++ b/tests/test-data-raw.sh
@@ -33,6 +33,7 @@
# Test the data plugin with raw= parameter.
+source ./functions.sh
set -e
set -x
@@ -66,16 +67,10 @@ pid="$(cat data-raw.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=data-raw.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > data-raw.out
diff --git a/tests/test-fua.sh b/tests/test-fua.sh
index f95aa18..f7c4571 100755
--- a/tests/test-fua.sh
+++ b/tests/test-fua.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
@@ -55,10 +56,6 @@ pid1= pid2= pid3= pid4=
# Kill any nbdkit processes on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
test "$pid1" && kill $pid1
test "$pid2" && kill $pid2
test "$pid3" && kill $pid3
@@ -73,10 +70,8 @@ cleanup ()
echo "Log 4 file contents:"
cat fua4.log || :
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Run four parallel nbdkit; to compare the logs and see what changes.
# 1: fuamode=none (default): client should send flush instead
diff --git a/tests/test-log.sh b/tests/test-log.sh
index f811de4..5ad5f22 100755
--- a/tests/test-log.sh
+++ b/tests/test-log.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
files="log.img log.log log.sock log.pid"
@@ -63,19 +64,13 @@ pid="$(cat log.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
# For easier debugging, dump the final log file before removing it.
echo "Log file contents:"
cat log.log
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Write, then read some data in the file.
qemu-io -f raw -c 'w -P 11 1M 2M' 'nbd+unix://?socket=log.sock'
diff --git a/tests/test-memory-largest-for-qemu.sh
b/tests/test-memory-largest-for-qemu.sh
index 9bc498d..65f69b6 100755
--- a/tests/test-memory-largest-for-qemu.sh
+++ b/tests/test-memory-largest-for-qemu.sh
@@ -34,6 +34,7 @@
# Test the memory plugin with the largest possible size supported
# by qemu and nbdkit.
+source ./functions.sh
set -e
files="memory-largest-for-qemu.out memory-largest-for-qemu.pid
memory-largest-for-qemu.sock"
@@ -68,16 +69,10 @@ pid="$(cat memory-largest-for-qemu.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Write some stuff to the beginning, middle and end.
qemu-io -f raw 'nbd+unix://?socket=memory-largest-for-qemu.sock' \
diff --git a/tests/test-memory-largest.sh b/tests/test-memory-largest.sh
index d0a6c77..d2cad1c 100755
--- a/tests/test-memory-largest.sh
+++ b/tests/test-memory-largest.sh
@@ -34,6 +34,7 @@
# Test the memory plugin with the largest possible size supported
# by nbdkit.
+source ./functions.sh
set -e
files="memory-largest.out memory-largest.pid memory-largest.sock"
@@ -69,16 +70,10 @@ pid="$(cat memory-largest.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# qemu cannot open this image!
#
diff --git a/tests/test-nozero.sh b/tests/test-nozero.sh
index 904d822..239d4bd 100755
--- a/tests/test-nozero.sh
+++ b/tests/test-nozero.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
files="nozero1.img nozero1.log nozero1.sock nozero1.pid
@@ -65,10 +66,6 @@ pid1= pid2= pid3= pid4= pid5a= pid5b=
# Kill any nbdkit processes on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
test "$pid1" && kill $pid1
test "$pid2" && kill $pid2
test "$pid3" && kill $pid3
@@ -89,10 +86,8 @@ cleanup ()
echo "Log 5b file contents:"
cat nozero5b.log || :
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Run four parallel nbdkit; to compare the logs and see what changes.
# 1: unfiltered, to check that qemu-io sends ZERO request and plugin trims
diff --git a/tests/test-offset2.sh b/tests/test-offset2.sh
index c37e060..2376301 100755
--- a/tests/test-offset2.sh
+++ b/tests/test-offset2.sh
@@ -33,6 +33,7 @@
# Additional test of the offset filter using the pattern plugin.
+source ./functions.sh
set -e
set -x
@@ -69,16 +70,10 @@ pid="$(cat offset2.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=offset2.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > offset2.out
diff --git a/tests/test-parallel-file.sh b/tests/test-parallel-file.sh
index fd88faa..1d27f93 100755
--- a/tests/test-parallel-file.sh
+++ b/tests/test-parallel-file.sh
@@ -31,6 +31,8 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
+
# Check file-data was created by Makefile and qemu-io exists.
if ! test -f file-data; then
echo "$0: missing file-data"
@@ -41,7 +43,7 @@ if ! qemu-io --version; then
exit 77
fi
-trap 'rm -f test-parallel-file.data test-parallel-file.out' 0 1 2 3 15
+cleanup_fn rm -f test-parallel-file.data test-parallel-file.out
# Populate file, and sanity check that qemu-io can issue parallel requests
printf '%1024s' . > test-parallel-file.data
diff --git a/tests/test-parallel-nbd.sh b/tests/test-parallel-nbd.sh
index cb70f46..7aa8a9f 100755
--- a/tests/test-parallel-nbd.sh
+++ b/tests/test-parallel-nbd.sh
@@ -31,6 +31,8 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
+
# Check file-data was created by Makefile and qemu-io exists.
if ! test -f file-data; then
echo "$0: missing file-data"
@@ -47,7 +49,7 @@ fi
files="test-parallel-nbd.out test-parallel-nbd.sock test-parallel-nbd.data
test-parallel-nbd.pid"
rm -f $files
-trap "rm -f $files" INT QUIT TERM EXIT ERR
+cleanup_fn rm -f $files
# Populate file, and sanity check that qemu-io can issue parallel requests
printf '%1024s' . > test-parallel-nbd.data
diff --git a/tests/test-pattern-largest-for-qemu.sh
b/tests/test-pattern-largest-for-qemu.sh
index cf70354..c2fa324 100755
--- a/tests/test-pattern-largest-for-qemu.sh
+++ b/tests/test-pattern-largest-for-qemu.sh
@@ -34,6 +34,7 @@
# Test the pattern plugin with the largest possible size supported
# by qemu and nbdkit.
+source ./functions.sh
set -e
files="pattern-largest-for-qemu.out pattern-largest-for-qemu.pid
pattern-largest-for-qemu.sock"
@@ -67,16 +68,10 @@ pid="$(cat pattern-largest-for-qemu.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=pattern-largest-for-qemu.sock' \
-c 'r -v 9223372036854774784 512' | grep -E '^[[:xdigit:]]+:'
> pattern-largest-for-qemu.out
diff --git a/tests/test-pattern-largest.sh b/tests/test-pattern-largest.sh
index 2a903bf..60a77b3 100755
--- a/tests/test-pattern-largest.sh
+++ b/tests/test-pattern-largest.sh
@@ -34,6 +34,7 @@
# Test the pattern plugin with the largest possible size supported
# by nbdkit.
+source ./functions.sh
set -e
files="pattern-largest.out pattern-largest.pid pattern-largest.sock"
@@ -67,16 +68,10 @@ pid="$(cat pattern-largest.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# qemu cannot open this image!
#
diff --git a/tests/test-pattern.sh b/tests/test-pattern.sh
index 68022c9..98c5139 100755
--- a/tests/test-pattern.sh
+++ b/tests/test-pattern.sh
@@ -38,6 +38,7 @@
# what read parameters we give it. Hence these tests are rather
# limited. (XXX)
+source ./functions.sh
set -e
files="pattern.out pattern.pid pattern.sock"
@@ -69,16 +70,10 @@ pid="$(cat pattern.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=pattern.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > pattern.out
diff --git a/tests/test-single.sh b/tests/test-single.sh
index 35017c8..7c7edfc 100755
--- a/tests/test-single.sh
+++ b/tests/test-single.sh
@@ -31,9 +31,9 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
-source ./functions.sh
if ! socat -h; then
echo "$0: 'socat' command not available"
@@ -56,16 +56,10 @@ pid=$!
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Wait for socat to start up and create the socket.
for i in `seq 1 10`; do
diff --git a/tests/test-tls-psk.sh b/tests/test-tls-psk.sh
index 99c5945..ac59a4c 100755
--- a/tests/test-tls-psk.sh
+++ b/tests/test-tls-psk.sh
@@ -31,9 +31,9 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
-source ./functions.sh
# Don't fail if certain commands aren't available.
if ! ss --version; then
@@ -97,16 +97,10 @@ pid="$(cat tls-psk.pid)"
# Kill the process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f tls-psk.pid tls-psk.out
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Run qemu-img against the server.
LANG=C \
diff --git a/tests/test-tls.sh b/tests/test-tls.sh
index 71bd8a4..1ba262e 100755
--- a/tests/test-tls.sh
+++ b/tests/test-tls.sh
@@ -31,9 +31,9 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -e
set -x
-source ./functions.sh
# Don't fail if certain commands aren't available.
if ! ss --version; then
@@ -91,16 +91,10 @@ pid="$(cat tls.pid)"
# Kill the process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f tls.pid tls.out
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
# Run qemu-img against the server.
LANG=C \
diff --git a/tests/test-truncate1.sh b/tests/test-truncate1.sh
index 719f63b..c4f3b63 100755
--- a/tests/test-truncate1.sh
+++ b/tests/test-truncate1.sh
@@ -33,6 +33,7 @@
# Test the truncate filter using the pattern plugin.
+source ./functions.sh
set -e
set -x
@@ -68,16 +69,10 @@ pid="$(cat truncate1.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=truncate1.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > truncate1.out
diff --git a/tests/test-truncate2.sh b/tests/test-truncate2.sh
index 0295b96..8a04661 100755
--- a/tests/test-truncate2.sh
+++ b/tests/test-truncate2.sh
@@ -33,6 +33,7 @@
# Test the truncate filter using the pattern plugin.
+source ./functions.sh
set -e
set -x
@@ -68,16 +69,10 @@ pid="$(cat truncate2.pid)"
# Kill the nbdkit process on exit.
cleanup ()
{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
kill $pid
rm -f $files
-
- exit $status
}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn cleanup
qemu-io -r -f raw 'nbd+unix://?socket=truncate2.sock' \
-c 'r -v 0 512' | grep -E '^[[:xdigit:]]+:' > truncate2.out
diff --git a/tests/test-zero.sh b/tests/test-zero.sh
index 2c5cece..636e735 100755
--- a/tests/test-zero.sh
+++ b/tests/test-zero.sh
@@ -31,6 +31,7 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+source ./functions.sh
set -x
set -e
@@ -42,18 +43,7 @@ fi
files="test-zero.out"
rm -f $files
-
-cleanup ()
-{
- status=$?
- trap '' INT QUIT TERM EXIT ERR
- echo $0: cleanup: exit code $status
-
- rm $files
-
- exit $status
-}
-trap cleanup INT QUIT TERM EXIT ERR
+cleanup_fn rm $files
nbdkit -U - zero --run 'qemu-img convert $nbd test-zero.out'
--
2.19.0.rc0