]> xenbits.xensource.com Git - people/sstabellini/mojo.git/.git/commitdiff
Add support for runtime QEMU containers
authorStefano Stabellini <sstabellini@kernel.org>
Fri, 19 Jan 2018 23:41:01 +0000 (15:41 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 22 Jan 2018 22:57:26 +0000 (14:57 -0800)
Introduce an option to build an Alpine based container with QEMU to run
the output image (nested virtualization).

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
build.sh
run-x86_64.sh [new file with mode: 0755]
runtime/build.sh [new file with mode: 0755]
runtime/qemu-system-x86_64/Dockerfile [new file with mode: 0644]
runtime/qemu-system-x86_64/build.yml [new file with mode: 0644]
runtime/qemu-system-x86_64/run.sh [new file with mode: 0755]
runtime/series [new file with mode: 0644]

index 27b8275dcdcea773ba4ae0d9f9518ce088605afc..c49bf3d01633aca0c30269a20046e9478af0dc4d 100644 (file)
--- 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 (executable)
index 0000000..fd44303
--- /dev/null
@@ -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 (executable)
index 0000000..608dc07
--- /dev/null
@@ -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 (file)
index 0000000..d600e28
--- /dev/null
@@ -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 (file)
index 0000000..f5a4580
--- /dev/null
@@ -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 (executable)
index 0000000..e8d8508
--- /dev/null
@@ -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 (file)
index 0000000..0e38e1b
--- /dev/null
@@ -0,0 +1 @@
+qemu-system-x86_64