diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-01-25 10:02:00 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-01-25 10:02:00 +0100 |
commit | 66b9374cc19c21ee5ff5b1344b43c991ac53ce91 (patch) | |
tree | b6b66736abd8226e7d3bcf1518a2bc4f17822158 /bin/debvm-run | |
parent | 88b229430a91354510224c960d30f427e078e8a8 (diff) | |
download | debvm-66b9374cc19c21ee5ff5b1344b43c991ac53ce91.tar.gz |
debvm-run: extract kernel image before inspecting it
Reported-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'bin/debvm-run')
-rwxr-xr-x | bin/debvm-run | 17 |
1 files changed, 11 insertions, 6 deletions
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" "$@" |