From 66b9374cc19c21ee5ff5b1344b43c991ac53ce91 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 25 Jan 2023 10:02:00 +0100 Subject: debvm-run: extract kernel image before inspecting it Reported-by: Arnd Bergmann --- bin/debvm-run | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/debvm-run b/bin/debvm-run index 10e19be..0c4ad2e 100755 --- a/bin/debvm-run +++ b/bin/debvm-run @@ -104,6 +104,13 @@ die() { echo "$*" 1>&2 exit 1 } +with_set_ex() { + local ret + echo "+ $*" 1>&2 + ret=0 + "$@" || ret=$? + test "$ret" = 0 || die "failed with exit code $ret" +} usage() { die "usage: $0 [-g] [-i image] [-s sshport] [-- qemu options]" } @@ -203,6 +210,9 @@ INITRDNAME=$(/sbin/debugfs "$IMAGE" -R "stat ${BOOTDIR}initrd.img" | sed 's/Fast test -n "$INITRDNAME" || die "failed to discover initrd image" test "${INITRDNAME#/}" = "$INITRDNAME" && INITRDNAME="$BOOTDIR$INITRDNAME" +with_set_ex /sbin/debugfs "$IMAGE" -R "cat $KERNELNAME" > "$KERNELTMP" +with_set_ex /sbin/debugfs "$IMAGE" -R "cat $INITRDNAME" > "$INITRDTMP" + # Refine our VMARCH guess from /bin/true using the kernel image to improve # experience for multiarch kernels. if command -v file >/dev/null 2>&1; then @@ -342,9 +352,4 @@ set -- \ -device "$NIC_DEV" \ "$@" -set -ex - -/sbin/debugfs "$IMAGE" -R "cat $KERNELNAME" > "$KERNELTMP" -/sbin/debugfs "$IMAGE" -R "cat $INITRDNAME" > "$INITRDTMP" - -"$QEMU" "$@" +with_set_ex "$QEMU" "$@" -- cgit v1.2.3