summaryrefslogtreecommitdiff
path: root/bin/debvm-run
diff options
context:
space:
mode:
Diffstat (limited to 'bin/debvm-run')
-rwxr-xr-xbin/debvm-run40
1 files changed, 27 insertions, 13 deletions
diff --git a/bin/debvm-run b/bin/debvm-run
index 53e2ba3..fe38a7a 100755
--- a/bin/debvm-run
+++ b/bin/debvm-run
@@ -74,7 +74,7 @@ F<rootfs.ext4>, resulting in an ephemeral run.
Make sure C<$TERM> is set to a value known inside the VM.
You may need to install B<ncurses-term> for more definitions.
The serial console will miss events of resizing the terminal emulator.
-You may run C<setterm -resize> in that case.
+You may run C<setterm --resize> in that case.
=item How can I kill debvm-run?
@@ -256,35 +256,52 @@ esac
KERNEL_CMDLINE="root=LABEL=$IMAGE_LABEL rw"
NETDEV="user,id=net0"
+KERNELFD=3
+while test -h "/proc/self/fd/$KERNELFD"; do
+ KERNELFD=$((KERNELFD + 1))
+done
+INITRDFD=$((KERNELFD + 1))
+while test -h "/proc/self/fd/$INITRDFD"; do
+ INITRDFD=$((INITRDFD + 1))
+done
+eval exec "$KERNELFD<"'"$KERNELTMP"'
+eval exec "$INITRDFD<"'"$INITRDTMP"'
+rm -f "$KERNELTMP" "$INITRDTMP"
+KERNELTMP=
+INITRDTMP=
+
set -- \
-no-user-config \
-name "debvm-run $IMAGE" \
-m 1G \
- -kernel "$KERNELTMP" \
- -initrd "$INITRDTMP" \
+ -kernel "/proc/self/fd/$KERNELFD" \
+ -initrd "/proc/self/fd/$INITRDFD" \
-drive "media=disk,format=raw,discard=unmap,file=$IMAGE,if=virtio,cache=unsafe" \
-object rng-random,filename=/dev/urandom,id=rng0 \
"$@"
-QEMU="qemu-system-$KERNELARCH"
+# Translate KERNELARCH (a Debian architecture) to a Debian CPU name.
+# This utilizes the QEMU Debian package symlink mapping that ensures that
+# calling qemu-system-${DEB_HOST_ARCH_CPU} will run the QEMU binary providing
+# the correct emulator for that CPU.
+KERNELARCHCPU="$(dpkg-architecture --force --host-arch "$KERNELARCH" --query DEB_HOST_ARCH_CPU)"
+QEMU="qemu-system-$KERNELARCHCPU"
CPU=
MACHINE=
MAX_SMP=
NIC_DEV=virtio-net-pci,netdev=net0
RNG_DEV=virtio-rng-pci,rng=rng0
-case "$KERNELARCH" in
+case "$KERNELARCHCPU" in
amd64)
- QEMU=qemu-system-x86_64
MACHINE="type=q35"
;;
- arm|armel|armhf)
+ arm)
CPU=max
MACHINE="type=virt"
MAX_SMP=8
;;
arm64)
- QEMU=qemu-system-aarch64
CPU=max,pauth-impdef=on
MACHINE="type=virt,gic-version=max"
;;
@@ -302,12 +319,8 @@ case "$KERNELARCH" in
MAX_SMP=1
;;
powerpc)
- QEMU=qemu-system-ppc
MAX_SMP=1
;;
- ppc64el)
- QEMU=qemu-system-ppc64
- ;;
riscv64)
MACHINE="type=virt"
;;
@@ -400,4 +413,5 @@ set -- \
-device "$NIC_DEV" \
"$@"
-with_set_ex "$QEMU" "$@"
+echo "+ $QEMU $*" 1>&2
+exec "$QEMU" "$@"