summaryrefslogtreecommitdiff
path: root/start-container-qemu.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-05-04 10:33:43 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2018-06-18 14:02:29 +0000
commit66aade778d67c603af723b698a3b6b890b469204 (patch)
treef9104ca4f5451d9ab53a99b67928635866eb7ba0 /start-container-qemu.sh
parentafad444cc3d029de9046669fbdb7e7d141f5ba8e (diff)
start-container-qemu.sh: Add support for non-KVM guests
Change-Id: Ic2cc2dc3a342583a9ac4305804f1c088a49b8ff9
Diffstat (limited to 'start-container-qemu.sh')
-rwxr-xr-xstart-container-qemu.sh22
1 files changed, 16 insertions, 6 deletions
diff --git a/start-container-qemu.sh b/start-container-qemu.sh
index cbb042ab..c0e98ffa 100755
--- a/start-container-qemu.sh
+++ b/start-container-qemu.sh
@@ -13,6 +13,7 @@ docker_args=()
initrd_url=""
kernel_url=""
prefix=""
+qemu="qemu-aarch64_host"
task="build"
weight="1"
@@ -21,6 +22,7 @@ while [ $# -gt 0 ]; do
--initrd_url) initrd_url="$2" ;;
--kernel_url) kernel_url="$2" ;;
--prefix) prefix="$2"; docker_args=("${docker_args[@]}" "$1" "$2") ;;
+ --qemu) qemu="$2" ;;
--task) task="$2"; docker_args=("${docker_args[@]}" "$1" "$2") ;;
--weight) weight="$2"; docker_args=("${docker_args[@]}" "$1" "$2") ;;
*) docker_args=("${docker_args[@]}" "$1" "$2")
@@ -74,11 +76,19 @@ done
container_exec sudo /etc/init.d/rpcbind start
container_exec sudo /etc/init.d/nfs-kernel-server start
-# /dev/kvm is chowned to root:kvm when qemu-system-arm package is installed.
-# We have this packaged installed, but /dev/kvm owner and permissions are not
-# preserved in container image.
-container_exec sudo chown root:kvm /dev/kvm
-container_exec sudo chmod g+rw /dev/kvm
+# $qemu == qemu-ARCH_CPU
+qemu_arch=$(echo "$qemu" | sed -e "s/^qemu-\(.*\)_\(.*\)/\1/")
+qemu_cpu=$(echo "$qemu" | sed -e "s/^qemu-\(.*\)_\(.*\)/\2/")
+
+kvm_opt=""
+if [ x"$qemu_cpu" = x"host" ]; then
+ # /dev/kvm is chowned to root:kvm when qemu-system-arm package is installed.
+ # We have this packaged installed, but /dev/kvm owner and permissions are
+ # not preserved in container image.
+ container_exec sudo chown root:kvm /dev/kvm
+ container_exec sudo chmod g+rw /dev/kvm
+ kvm_opt="-enable-kvm"
+fi
# CPU is limited (on contention) by docker container.
ncpus=$(container_exec nproc --all)
@@ -94,7 +104,7 @@ rsync -e "ssh -p$port" -az "$(ls $(basename "$initrd_url"))" "$host:/tmp/initrd"
# "-f" is to start qemu in the background.
# "-Snone" is to avoid mixing this session with any other shared sessions.
remote_exec "$host:$port:/:-f -Snone" \
- qemu-system-aarch64 -machine virt -enable-kvm -cpu host \
+ qemu-system-$qemu_arch -machine virt $kvm_opt -cpu $qemu_cpu \
-smp $ncpus -m $memory -nographic -monitor none \
-kernel /tmp/kernel -initrd /tmp/initrd \
-append "root=/dev/nfs nfsroot=$nfsip:$nfsroot,udp rw ip=dhcp" \