summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-01-25 12:32:05 +0100
committerHelmut Grohne <helmut@subdivi.de>2023-01-25 12:32:05 +0100
commitc8398b34897301081ca45804d5003c74237b7452 (patch)
tree78ba47e80bb0c7912af8fe2b31f7f27b81bf75ef
parent6f9e95308cdd0497e2a4f35d870aa8015a81b60a (diff)
downloaddebvm-c8398b34897301081ca45804d5003c74237b7452.tar.gz
debvm-run: internally differentiate between VMARCH and KERNELARCH
In a multiarch setting, VMARCH shall describe the contained userland and KERNELARCH shall describe the architecture of the contained kernel.
-rwxr-xr-xbin/debvm-run24
1 files changed, 12 insertions, 12 deletions
diff --git a/bin/debvm-run b/bin/debvm-run
index 1055467..0e9403f 100755
--- a/bin/debvm-run
+++ b/bin/debvm-run
@@ -214,17 +214,17 @@ 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.
+# Guess the kernel architecture.
+KERNELARCH=$VMARCH
if command -v file >/dev/null 2>&1; then
case "$VMARCH:$(file -b "$KERNELTMP")" in
- "arm:Linux kernel ARM64 boot executable Image"*) VMARCH=arm64 ;;
- "armel:Linux kernel ARM64 boot executable Image"*) VMARCH=arm64 ;;
- "armhf:Linux kernel ARM64 boot executable Image"*) VMARCH=arm64 ;;
+ "arm:Linux kernel ARM64 boot executable Image"*) KERNELARCH=arm64 ;;
+ "armel:Linux kernel ARM64 boot executable Image"*) KERNELARCH=arm64 ;;
+ "armhf:Linux kernel ARM64 boot executable Image"*) KERNELARCH=arm64 ;;
# The boot stub looks the same on i386 and amd64, so we
# actually inspect the kernel version here, which happens to
# include amd64 for Debian kernels.
- "i386:Linux kernel x86 boot executable bzImage, version "*"-amd64 "*) VMARCH=amd64 ;;
+ "i386:Linux kernel x86 boot executable bzImage, version "*"-amd64 "*) KERNELARCH=amd64 ;;
esac
fi
@@ -241,14 +241,14 @@ set -- \
-object rng-random,filename=/dev/urandom,id=rng0 \
"$@"
-QEMU="qemu-system-$VMARCH"
+QEMU="qemu-system-$KERNELARCH"
CPU=
MACHINE=
MAX_SMP=
NIC_DEV=virtio-net-pci,netdev=net0
RNG_DEV=virtio-rng-pci,rng=rng0
-case "$VMARCH" in
+case "$KERNELARCH" in
amd64)
QEMU=qemu-system-x86_64
MACHINE="type=q35"
@@ -292,7 +292,7 @@ case "$VMARCH" in
;;
esac
-if test "$ARCHITECTURE" = "$VMARCH"; then
+if test "$ARCHITECTURE" = "$KERNELARCH"; then
if ! command -v "$QEMU" >/dev/null 2>&1; then
# Fall back to kvm in case we badly guessed qemu.
QEMU=kvm
@@ -303,7 +303,7 @@ if test "$ARCHITECTURE" = "$VMARCH"; then
if test -w /dev/kvm; then
CPU=host
fi
- if test "$VMARCH" = arm64; then
+ if test "$KERNELARCH" = arm64; then
MACHINE="$MACHINE,gic-version=max"
fi
fi
@@ -325,7 +325,7 @@ fi
if test -z "$GRAPHICAL"; then
set -- -nographic "$@"
- case "$VMARCH" in
+ case "$KERNELARCH" in
amd64|i386)
KERNEL_CMDLINE="$KERNEL_CMDLINE console=ttyS0"
;;
@@ -334,7 +334,7 @@ if test -z "$GRAPHICAL"; then
KERNEL_CMDLINE="$KERNEL_CMDLINE TERM=$TERM"
fi
else
- case "$VMARCH" in
+ case "$KERNELARCH" in
amd64|i386)
set -- -vga virtio "$@"
;;