summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml5
-rwxr-xr-xbin/debvm-run40
-rw-r--r--debian/control3
-rwxr-xr-xshare/customize-autologin.sh8
4 files changed, 37 insertions, 19 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index baea94c..e8b7754 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,7 +27,7 @@ release_test:
script:
- apt-get update
- apt-get dist-upgrade --yes
- - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client qemu-kvm
+ - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client qemu-kvm dpkg-dev
- PATH=$(pwd)/bin:$PATH ./tests/create-and-run.sh $(dpkg --print-architecture) "$RELEASE"
arch_test:
@@ -46,5 +46,6 @@ arch_test:
- test -e /proc/sys/fs/binfmt_misc/status || mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
- apt-get update
- apt-get dist-upgrade --yes
- - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client qemu-system binfmt-support arch-test qemu-user-static file
+ - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client qemu-system arch-test qemu-user-static file systemd dpkg-dev
+ - /lib/systemd/systemd-binfmt
- PATH=$(pwd)/bin:$PATH ./tests/create-and-run.sh "$ARCHITECTURE" sid
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" "$@"
diff --git a/debian/control b/debian/control
index 60112be..0d63dff 100644
--- a/debian/control
+++ b/debian/control
@@ -13,11 +13,12 @@ Package: debvm
Architecture: all
Depends:
${misc:Depends},
+ dpkg-dev,
e2fsprogs,
genext2fs,
mmdebstrap (>= 1.3.0),
passwd,
- qemu-kvm | qemu-system-arm | qemu-system-mips | qemu-system-misc | qemu-system-ppc | qemu-system-sparc | qemu-system-x86,
+ qemu-kvm (>> 1:8.0) | qemu-system-any
# Required for -device virtio-net-pci,netdev=net0
ipxe-qemu,
Recommends:
diff --git a/share/customize-autologin.sh b/share/customize-autologin.sh
index 7b7a130..da386b5 100755
--- a/share/customize-autologin.sh
+++ b/share/customize-autologin.sh
@@ -5,24 +5,26 @@
# This is a mmdebstrap customize hook that configures automatic root login on a
# serial console. It also parses the TERM kernel cmdline and passes it as
# TERM to agetty. Since serial consoles do not transmit SIGWINCH, it causes
-# the shell to run setterm -resize on interactive, serial logins.
+# the shell to run setterm --resize on interactive, serial logins.
set -eu
TARGET=$1
-cat >"$TARGET/etc/profile.d/resize_serial_term.sh" <<'EOF'
+if dpkg --compare-versions "$(dpkg-query --root "$TARGET" -f '${Version}' -W util-linux)" ge 2.33; then
+ cat >"$TARGET/etc/profile.d/resize_serial_term.sh" <<'EOF'
if test -n "${TERM-}" && test -n "${PS1-}"; then
case "$(tty)" in
/dev/tty[0-9]*)
;;
/dev/tty*)
# Assume that every other tty is serial and should be resized.
- setterm -resize
+ setterm --resize
;;
esac
fi
EOF
+fi
if test "$(dpkg-query --root "$TARGET" -f '${db:Status-Status}' -W systemd-sysv 2>/dev/null)" = installed; then
UNIT=serial-getty@.service