diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-02-02 09:52:13 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-02-02 09:52:13 +0100 |
commit | ebd9704f6f1c6879c3300ddcf74e55cbd1fac057 (patch) | |
tree | 656eaf2e478ec2f25bfb2fc0bc0142337d405fa2 | |
parent | 09bcaa8fe9011bdbad53749bd7e0531b4be6e2ba (diff) | |
download | debvm-ebd9704f6f1c6879c3300ddcf74e55cbd1fac057.tar.gz |
debvm-run: deal with arbitrary disk labels
Reported-by: Gioele Barabucci <gioele@svario.it>
Closes: #1030255
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | bin/debvm-run | 18 |
2 files changed, 13 insertions, 7 deletions
@@ -40,7 +40,7 @@ installed: What is this image format precisely? ==================================== -The image is a sparse ext4 file system image with a disk label "debvm". It +The image is a sparse ext4 file system image with a non-empty disk label. It 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: diff --git a/bin/debvm-run b/bin/debvm-run index 9cfce7f..53bfb3b 100755 --- a/bin/debvm-run +++ b/bin/debvm-run @@ -14,7 +14,7 @@ B<debvm-run> [B<-g>] [B<-i> F<image>] [B<-s> I<sshport>] [B<--> I<qemu options>] =head1 DESCRIPTION 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 virtual machine image is expected to be a raw ext4 image with a non-empty file system label. 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 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>. @@ -173,10 +173,6 @@ if ! printf '\123\357' | cmp --bytes=2 "$IMAGE" - 1080; then die "image '$IMAGE' is not in ext4 format" fi -if ! printf 'debvm\000' | cmp --bytes=6 "$IMAGE" - 1144; then - die "image '$IMAGE' was not created by debvm-create (wrong disk label)" -fi - cleanup() { set +x test -n "$KERNELTMP" && rm -f "$KERNELTMP" @@ -231,7 +227,17 @@ if command -v file >/dev/null 2>&1; then esac fi -KERNEL_CMDLINE="root=LABEL=debvm rw" +IMAGE_LABEL="$(/sbin/e2label "$IMAGE")" +case "$IMAGE_LABEL" in + "") + die "debvm-run requires a non-empty filesystem label" + ;; + *" "*) + die "debvm-run requires a filesystem label without spaces" + ;; +esac + +KERNEL_CMDLINE="root=LABEL=$IMAGE_LABEL rw" NETDEV="user,id=net0" set -- \ |