From 6726746484e37f31fba3c307e133c405c9a80096 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Thu, 30 Mar 2017 21:50:33 +0100 Subject: [PATCH] Add a runner for UEFI ISOs Fixes #480 Signed-off-by: Dave Tucker --- .gitignore | 2 +- Makefile | 9 ++++++++- scripts/qemu.sh | 2 +- tools/qemu/Dockerfile | 5 ++++- tools/qemu/Makefile | 2 +- tools/qemu/qemu.sh | 15 ++++++++++++--- tools/qemu/repositories | 2 ++ 7 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 tools/qemu/repositories diff --git a/.gitignore b/.gitignore index c75f8f577..0f635c5a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -test.log +*.log Dockerfile.media /bin disk.img.* diff --git a/Makefile b/Makefile index 52f0a3ef4..23b62065a 100644 --- a/Makefile +++ b/Makefile @@ -34,13 +34,20 @@ test-initrd.img: bin/moby test/test.yml test-bzImage: test-initrd.img # interactive versions need to use volume mounts -.PHONY: qemu qemu-iso +.PHONY: qemu qemu-iso qemu-efi test-qemu-efi qemu: moby-initrd.img moby-bzImage moby-cmdline ./scripts/qemu.sh moby-initrd.img moby-bzImage "$(shell cat moby-cmdline)" qemu-iso: alpine/mobylinux-bios.iso ./scripts/qemu.sh $^ +qemu-efi: moby-efi.iso + ./scripts/qemu.sh $^ + +test-qemu-efi: test-efi.iso + ./scripts/qemu.sh $^ 2>&1 | tee test-efi.log + $(call check_test_log, test-efi.log) + bin: mkdir -p $@ diff --git a/scripts/qemu.sh b/scripts/qemu.sh index 01021f551..18d4ed264 100755 --- a/scripts/qemu.sh +++ b/scripts/qemu.sh @@ -1,6 +1,6 @@ #!/bin/sh -QEMU_IMAGE=mobylinux/qemu:75ef01c780850daf78ee45078606eb740a999edf@sha256:ec93951816b57d86f7a90c129a5580e083093e5a92263d0d2be6822daa2162dd +QEMU_IMAGE=mobylinux/qemu:ac2f8d3258d09541f0dab7529f62bb7e9b9bb79c@sha256:b60d1421937b0ebf4846341a1cda1ca00f44a45553d5494080b2ca8aac468773 # if not interactive if [ ! -t 0 -a -z "$1" ] diff --git a/tools/qemu/Dockerfile b/tools/qemu/Dockerfile index f9b2be6b5..8bd33fd64 100644 --- a/tools/qemu/Dockerfile +++ b/tools/qemu/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.5 +FROM alpine:edge + +COPY repositories /etc/apk/ RUN \ apk update && apk upgrade && \ @@ -7,6 +9,7 @@ RUN \ qemu-img \ qemu-system-arm \ qemu-system-x86_64 \ + ovmf@testing \ && true COPY . . diff --git a/tools/qemu/Makefile b/tools/qemu/Makefile index 8150dd723..20e6756f6 100644 --- a/tools/qemu/Makefile +++ b/tools/qemu/Makefile @@ -5,7 +5,7 @@ IMAGE=qemu default: push -hash: Dockerfile qemu.sh +hash: Dockerfile qemu.sh repositories DOCKER_CONTENT_TRUST=1 docker pull $(BASE) tar cf - $^ | docker build --no-cache -t $(IMAGE):build - docker run --rm --entrypoint /bin/sh $(IMAGE):build -c 'cat Dockerfile qemu.sh /lib/apk/db/installed | sha1sum' | sed 's/ .*//' > $@ diff --git a/tools/qemu/qemu.sh b/tools/qemu/qemu.sh index eb791b6d6..774115f3d 100755 --- a/tools/qemu/qemu.sh +++ b/tools/qemu/qemu.sh @@ -11,20 +11,24 @@ cd /tmp TGZ="$(find . -name '*.tgz' -or -name '*.tar.gz')" [ -n "$TGZ" ] && bsdtar xzf "$TGZ" +EFI_ISO="$(find . -name '*efi.iso')" ISO="$(find . -name '*.iso')" RAW="$(find . -name '*.raw')" INITRD="$(find . -name '*.img')" KERNEL="$(find . -name vmlinuz64 -or -name '*bzImage')" CMDLINE="$(find . -name '*-cmdline')" -if [ -n "$ISO" ] +if [ -n "$EFI_ISO" ] +then + ARGS="-pflash /usr/share/ovmf/bios.bin -usbdevice tablet -cdrom $EFI_ISO -boot d -drive file=systemdisk.img,format=raw" +elif [ -n "$ISO" ] then ARGS="-cdrom $ISO -drive file=systemdisk.img,format=raw" elif [ -n "$RAW" ] then # should test with more drives ARGS="-drive file=$RAW,format=raw" -elif [ -n "KERNEL" ] +elif [ -n "$KERNEL" ] then ARGS="-kernel $KERNEL" if [ -n "$INITRD" ] @@ -50,4 +54,9 @@ then CMDLINE="console=ttyS0" fi -qemu-system-x86_64 -machine q35,accel=kvm:tcg -device virtio-rng-pci -serial stdio -vnc none -m 1024 -append "${CMDLINE}" $ARGS +if [ -z "$EFI_ISO" ] && [ -z "$ISO" ] +then + ARGS="-append ${CMDLINE} ${ARGS}" +fi + +qemu-system-x86_64 -machine q35,accel=kvm:tcg -device virtio-rng-pci -nographic -vnc none -m 1024 $ARGS diff --git a/tools/qemu/repositories b/tools/qemu/repositories new file mode 100644 index 000000000..a276cf86e --- /dev/null +++ b/tools/qemu/repositories @@ -0,0 +1,2 @@ +http://dl-cdn.alpinelinux.org/alpine/edge/main +@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing