Skip to content

Check KVM support on any X64 Linux runner #1428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,24 @@ runs:
# https://github.com/reactivecircus/android-emulator-runner?tab=readme-ov-file#running-hardware-accelerated-emulators-on-linux-runners
# https://github.com/ankidroid/Anki-Android/commit/3a5ecaa9837691817022d11b0dbe383b8e82d9fe
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Enable KVM group perms
if: contains(fromJSON(env.os_value),'ubuntu-latest') || contains(fromJSON(env.os_value),'ubuntu-22.04')
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger -v --name-match=kvm

- name: Test KVM
if: contains(fromJSON(env.os_value),'ubuntu-latest') || contains(fromJSON(env.os_value),'ubuntu-22.04')
- name: Check KVM permissions
shell: bash
if: runner.os == 'Linux' && runner.arch == 'X64'
continue-on-error: true
run: |
set -x
sudo apt-get update
sudo apt-get install -y --no-install-recommends cpu-checker

ls -al /dev/kvm
test -w /dev/kvm
if ! command -v kvm-ok > /dev/null 2>&1
then
sudo apt-get update
sudo apt-get install -y cpu-checker
fi

if ! kvm-ok
then
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger -v --name-match=kvm
fi

kvm-ok
24 changes: 19 additions & 5 deletions .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3355,13 +3355,27 @@ jobs:
# https://github.com/reactivecircus/android-emulator-runner?tab=readme-ov-file#running-hardware-accelerated-emulators-on-linux-runners
# https://github.com/ankidroid/Anki-Android/commit/3a5ecaa9837691817022d11b0dbe383b8e82d9fe
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Enable KVM group perms
if: contains(fromJSON('["ubuntu-22.04","ubuntu-24.04","ubuntu-latest"]'), matrix.runs_on[0])
- name: Check KVM permissions
if: runner.os == 'Linux' && runner.arch == 'X64'
continue-on-error: true
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger -v --name-match=kvm
if ! command -v kvm-ok > /dev/null 2>&1
then
sudo apt-get update
sudo apt-get install -y cpu-checker
fi

if ! kvm-ok
then
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger -v --name-match=kvm
fi

if ! kvm-ok
then
echo "::warn::KVM is not supported"
fi

# run docker compose tests and print the logs from all services
- name: Run docker compose tests
Expand Down
Loading