summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/debvm-run26
1 files changed, 14 insertions, 12 deletions
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"