From: Stefano Stabellini Date: Fri, 19 Jan 2018 23:41:01 +0000 (-0800) Subject: Add support for runtime QEMU containers X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a462d72e871b7dc00824c75227560acec9a34926;p=people%2Fsstabellini%2Fmojo.git%2F.git Add support for runtime QEMU containers Introduce an option to build an Alpine based container with QEMU to run the output image (nested virtualization). Signed-off-by: Stefano Stabellini --- diff --git a/build.sh b/build.sh index 27b8275..c49bf3d 100644 --- a/build.sh +++ b/build.sh @@ -7,3 +7,6 @@ done # Create final image. Output is out/image. mkimage/build.sh + +# Build runtime execution environments +runtime/build.sh diff --git a/run-x86_64.sh b/run-x86_64.sh new file mode 100755 index 0000000..fd44303 --- /dev/null +++ b/run-x86_64.sh @@ -0,0 +1 @@ +docker run --privileged -v `pwd`/out:/out -it mojoos/qemu-system-x86_64:qemu-system-x86_64 /root/run.sh /out/image diff --git a/runtime/build.sh b/runtime/build.sh new file mode 100755 index 0000000..608dc07 --- /dev/null +++ b/runtime/build.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +build() { + label=$1 + + if test `which linuxkit` + then + linuxkit pkg build --disable-content-trust -hash $label runtime/$label/ + else + exists=`docker images -q "mojoos/$label"` + if test -z "$exists" + then + docker build -f runtime/$label/Dockerfile -t mojoos/$label runtime/$label + fi + fi +} + +for label in `cat runtime/series` +do + build $label +done diff --git a/runtime/qemu-system-x86_64/Dockerfile b/runtime/qemu-system-x86_64/Dockerfile new file mode 100644 index 0000000..d600e28 --- /dev/null +++ b/runtime/qemu-system-x86_64/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.6 as qemu-system-x86_64 + +COPY run.sh /root + +RUN \ + apk update && \ + apk add qemu-system-x86_64 ovmf diff --git a/runtime/qemu-system-x86_64/build.yml b/runtime/qemu-system-x86_64/build.yml new file mode 100644 index 0000000..f5a4580 --- /dev/null +++ b/runtime/qemu-system-x86_64/build.yml @@ -0,0 +1,3 @@ +image: qemu-system-x86_64 +org: mojoos +network: yes diff --git a/runtime/qemu-system-x86_64/run.sh b/runtime/qemu-system-x86_64/run.sh new file mode 100755 index 0000000..e8d8508 --- /dev/null +++ b/runtime/qemu-system-x86_64/run.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +DISK1=$1 + +qemu-system-x86_64 -m 4G -smp 2 --enable-kvm -cpu core2duo,+vmx \ + -nographic -serial stdio -monitor none \ + --bios /usr/share/ovmf/bios.bin \ + -netdev user,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,bus=pci.0,addr=0x3 \ + -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \ + -drive file=$DISK1,if=none,id=drive-virtio-disk0,format=raw,cache=none \ + -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ + -device virtio-rng-pci diff --git a/runtime/series b/runtime/series new file mode 100644 index 0000000..0e38e1b --- /dev/null +++ b/runtime/series @@ -0,0 +1 @@ +qemu-system-x86_64