diff options
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rwxr-xr-x | bin/debvm-run | 26 |
3 files changed, 20 insertions, 18 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29e0783..4604045 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ codespell: - apt-get update - apt-get dist-upgrade --yes - apt-get --no-install-recommends --yes install codespell - - codespell bin/* share/*.sh tests/*.sh + - codespell bin/* share/*.sh tests/*.sh README.md release_test: parallel: @@ -45,10 +45,10 @@ contains the root filesystem of a (Debian) installation including an init system and a kernel. There is no partition table or bootloader. The following paths are assumed inside: * `/bin/true` is used to detect the architecture of an image - * `/vmlinuz` or `/vmlinux` (depending on the architecture) must be a symbolic - link pointing to a regular file containing the kernel. - * `/initrd.img` must be a symbolic link pointing to a regular file containing - the initrd image. + * `(|/boot)/vmlinu[xz]` must be a symbolic link pointing to a regular file + containing the kernel. + * `initrd.img` must be a symbolic link in the same directory as the kernel + image pointing to a regular file containing the initrd image. Why? ==== @@ -63,7 +63,7 @@ The other aspect is restricting to Debian-based systems. This allows for a lot of simplification of the problem space. While most similar tools require root privileges at some point, this one works -with either fakeroot or a subuid allocation for user namepsaces, which is often +with either fakeroot or a subuid allocation for user namespaces, which is often available. The implementation is so short that it still is feasible to read and understand diff --git a/bin/debvm-run b/bin/debvm-run index 6ed47c4..e36ea60 100755 --- a/bin/debvm-run +++ b/bin/debvm-run @@ -16,7 +16,7 @@ B<debvm-run> [B<-g>] [B<-i> F<image>] [B<-s> I<sshport>] [B<--> I<qemu options>] B<debvm-run> is essentially a thin wrapper around B<qemu> for running a virtual machine image created by B<debvm-create> or something compatible. The virtual machine image is expected to be a raw ext4 image with file system label B<debvm>. The architecture of the machine is detected from the contained F</bin/true>. -It must contain a symbolic link pointing to a kernel image at F</vmlinuz> or F</vmlinux> depending on the architecture and a symbolic link pointing to an initrd image at F</initrd.img>. +It must contain a symbolic link pointing to a kernel image at one of F<(|/boot)/vmlinu[xz]> a symbolic link pointing to an initrd image at F<initrd.img> in the same directory as the kernel image. Both are extracted and passed to B<qemu>. A net interface configured for user mode is added automatically. @@ -186,20 +186,22 @@ if command -v elf-arch >/dev/null 2>&1; then /sbin/debugfs "$IMAGE" -R "cat /bin/true" > "$KERNELTMP" VMARCH=$(elf-arch "$KERNELTMP") fi -case "$VMARCH" in - mips*|ppc64el) - KERNELLINK=vmlinux - ;; - *) - KERNELLINK=vmlinuz - ;; -esac - -KERNELNAME=$(/sbin/debugfs "$IMAGE" -R "stat $KERNELLINK" | sed 's/Fast link dest: "\(.*\)"/\1/;t;d') -INITRDNAME=$(/sbin/debugfs "$IMAGE" -R "stat initrd.img" | sed 's/Fast link dest: "\(.*\)"/\1/;t;d') +for KERNELLINK in vmlinuz vmlinux boot/vmlinuz boot/vmlinux; do + KERNELNAME=$(/sbin/debugfs "$IMAGE" -R "stat $KERNELLINK" | sed 's/Fast link dest: "\(.*\)"/\1/;t;d') + test -n "$KERNELNAME" && break +done +if test "${KERNELLINK%/*}" = "$KERNELLINK"; then + BOOTDIR= +else + BOOTDIR="${KERNELLINK%/*}/" +fi test -n "$KERNELNAME" || die "failed to discover kernel image" +test "${KERNELNAME#/}" = "$KERNELNAME" && KERNELNAME="$BOOTDIR$KERNELNAME" + +INITRDNAME=$(/sbin/debugfs "$IMAGE" -R "stat ${BOOTDIR}initrd.img" | sed 's/Fast link dest: "\(.*\)"/\1/;t;d') test -n "$INITRDNAME" || die "failed to discover initrd image" +test "${INITRDNAME#/}" = "$INITRDNAME" && INITRDNAME="$BOOTDIR$INITRDNAME" KERNEL_CMDLINE="root=LABEL=debvm rw" NETDEV="user,id=net0" |