From 487eefbeb9d242f8e29f69e568278adefdc87043 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 2 Feb 2024 11:52:57 +0100 Subject: [PATCH] feat: Initial arm64 support (#420) --- .github/workflows/build.yml | 7 ------- Dockerfile | 2 +- docker-compose.yml | 2 +- readme.md | 22 +++++++++++----------- src/display.sh | 28 ---------------------------- src/entry.sh | 4 ++-- src/proc.sh | 12 ++++-------- src/reset.sh | 4 ++-- 8 files changed, 21 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 538ec34..8801293 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,10 +96,3 @@ jobs: uses: action-pack/bump@v2 with: token: ${{ secrets.REPO_ACCESS_TOKEN }} - - - name: Push to Gitlab mirror - uses: action-pack/gitlab-sync@v3 - with: - url: ${{ secrets.GITLAB_URL }} - token: ${{ secrets.GITLAB_TOKEN }} - username: ${{ secrets.GITLAB_USERNAME }} diff --git a/Dockerfile b/Dockerfile index 7a786c2..04e8f78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN apt-get update \ qemu-utils \ ca-certificates \ netcat-openbsd \ - qemu-system-x86 \ + qemu-system-arm \ && apt-get clean \ && novnc="1.4.0" \ && mkdir -p /usr/share/novnc \ diff --git a/docker-compose.yml b/docker-compose.yml index 45136e7..e04c194 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: RAM_SIZE: "1G" CPU_CORES: "1" DISK_SIZE: "16G" - BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.0-x86_64.iso" + BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/aarch64/alpine-virt-3.19.1-aarch64.iso" devices: - /dev/kvm device_cgroup_rules: diff --git a/readme.md b/readme.md index 82734f3..1ba5bec 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@

QEMU
- +
@@ -11,7 +11,7 @@

-QEMU in a docker container for running x86 and x64 virtual machines. +QEMU in a docker container for running ARM-based virtual machines. It uses high-performance QEMU options (like KVM acceleration, kernel-mode networking, IO threading, etc.) to achieve near-native speed. @@ -30,9 +30,9 @@ version: "3" services: qemu: container_name: qemu - image: qemux/qemu-docker + image: qemux/qemu-arm environment: - BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.0-x86_64.iso" + BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/aarch64/alpine-virt-3.19.1-aarch64.iso" devices: - /dev/kvm cap_add: @@ -218,11 +218,11 @@ docker run -it --rm -e "BOOT=http://example.com/image.iso" -p 8006:8006 --device ARGUMENTS: "-device usb-tablet" ``` -[build_url]: https://github.com/qemus/qemu-docker/ -[hub_url]: https://hub.docker.com/r/qemux/qemu-docker/ -[tag_url]: https://hub.docker.com/r/qemux/qemu-docker/tags +[build_url]: https://github.com/qemus/qemu-arm/ +[hub_url]: https://hub.docker.com/r/qemux/qemu-arm/ +[tag_url]: https://hub.docker.com/r/qemux/qemu-arm/tags -[Build]: https://github.com/qemus/qemu-docker/actions/workflows/build.yml/badge.svg -[Size]: https://img.shields.io/docker/image-size/qemux/qemu-docker/latest?color=066da5&label=size -[Pulls]: https://img.shields.io/docker/pulls/qemux/qemu-docker.svg?style=flat&label=pulls&logo=docker -[Version]: https://img.shields.io/docker/v/qemux/qemu-docker/latest?arch=amd64&sort=semver&color=066da5 +[Build]: https://github.com/qemus/qemu-arm/actions/workflows/build.yml/badge.svg +[Size]: https://img.shields.io/docker/image-size/qemux/qemu-arm/latest?color=066da5&label=size +[Pulls]: https://img.shields.io/docker/pulls/qemux/qemu-arm.svg?style=flat&label=pulls&logo=docker +[Version]: https://img.shields.io/docker/v/qemux/qemu-arm/latest?arch=arm64&sort=semver&color=066da5 diff --git a/src/display.sh b/src/display.sh index 6272103..a21fc8e 100644 --- a/src/display.sh +++ b/src/display.sh @@ -22,32 +22,4 @@ case "${DISPLAY,,}" in ;; esac -if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then - return 0 -fi - -[[ "${VGA,,}" == "virtio" ]] && VGA="virtio-gl" -DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128" -DISPLAY_OPTS="$DISPLAY_OPTS -vga $VGA" - -[[ "${DISPLAY,,}" == "vnc" ]] && DISPLAY_OPTS="$DISPLAY_OPTS -vnc :0" -[[ "${DISPLAY,,}" == "web" ]] && DISPLAY_OPTS="$DISPLAY_OPTS -vnc :0,websocket=5700" - -[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri - -if [ ! -c /dev/dri/card0 ]; then - if mknod /dev/dri/card0 c 226 0; then - chmod 666 /dev/dri/card0 - fi -fi - -if [ ! -c /dev/dri/renderD128 ]; then - if mknod /dev/dri/renderD128 c 226 128; then - chmod 666 /dev/dri/renderD128 - fi -fi - -addPackage "xserver-xorg-video-intel" "Intel GPU drivers" -addPackage "qemu-system-modules-opengl" "OpenGL module" - return 0 diff --git a/src/entry.sh b/src/entry.sh index eb3be8b..e438fdd 100755 --- a/src/entry.sh +++ b/src/entry.sh @@ -2,7 +2,7 @@ set -Eeuo pipefail APP="QEMU" -SUPPORT="https://github.com/qemus/qemu-docker" +SUPPORT="https://github.com/qemus/qemu-arm" cd /run @@ -20,4 +20,4 @@ trap - ERR info "Booting image using $VERS..." [[ "$DEBUG" == [Yy1]* ]] && set -x -exec qemu-system-x86_64 ${ARGS:+ $ARGS} +exec qemu-system-aarch64 ${ARGS:+ $ARGS} diff --git a/src/proc.sh b/src/proc.sh index 648224d..f0c1c75 100644 --- a/src/proc.sh +++ b/src/proc.sh @@ -7,7 +7,7 @@ set -Eeuo pipefail : "${CPU_FLAGS:=""}" : "${CPU_MODEL:="host"}" -[ "$ARCH" != "amd64" ] && KVM="N" +[ "$ARCH" != "arm"* ] && KVM="N" if [[ "$KVM" != [Nn]* ]]; then @@ -18,10 +18,6 @@ if [[ "$KVM" != [Nn]* ]]; then else if ! sh -c 'echo -n > /dev/kvm' &> /dev/null; then KVM_ERR="(no write access)" - else - if ! grep -q -e vmx -e svm /proc/cpuinfo; then - KVM_ERR="(vmx/svm disabled)" - fi fi fi @@ -48,14 +44,14 @@ if [[ "$KVM" != [Nn]* ]]; then else KVM_OPTS="" - CPU_FEATURES="+ssse3,+sse4.1,+sse4.2" + CPU_FEATURES="" if [[ "${CPU_MODEL,,}" == "host"* ]]; then - if [[ "$ARCH" == "amd64" ]]; then + if [[ "$ARCH" == "arm"* ]]; then CPU_MODEL="max" else - CPU_MODEL="qemu64" + CPU_MODEL="cortex-a76" fi fi diff --git a/src/reset.sh b/src/reset.sh index 0690a8f..6d7cc45 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -18,7 +18,7 @@ echo : "${BOOT:=""}" # URL of the ISO file : "${DEBUG:="N"}" # Disable debugging -: "${MACHINE:="q35"}" # Machine selection +: "${MACHINE:="virt"}" # Machine selection : "${ALLOCATE:=""}" # Preallocate diskspace : "${ARGUMENTS:=""}" # Extra QEMU parameters : "${CPU_CORES:="1"}" # Amount of CPU cores @@ -39,7 +39,7 @@ HOST=$(hostname -s) KERNEL=$(uname -r | cut -b 1) MINOR=$(uname -r | cut -d '.' -f2) ARCH=$(dpkg --print-architecture) -VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1) +VERS=$(qemu-system-aarch64 --version | head -n 1 | cut -d '(' -f 1) # Check system