ci: set kvm permissions for GHA QEMU jobs
authorVincent Fu <vincent.fu@samsung.com>
Fri, 4 Apr 2025 11:41:50 +0000 (07:41 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Fri, 4 Apr 2025 15:27:27 +0000 (11:27 -0400)
The image used by GitHub-hosted runners changed the default kvm device
permissions recently rendering us no longer able to start guest VMs. The
error message:

Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize kvm: Permission denied

Working run: https://github.com/fiotestbot/fio/actions/runs/14186873066
Failed run: https://github.com/fiotestbot/fio/actions/runs/14211189491

Explicitly give the GitHub Actions runner user permission to access the
/dev/kvm device following the guide at

https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
.github/actions/start-vm/action.yml

index 3449aac5bce197fd5d5bfa008255c090edf5bb41..ab13aa091ae1591955342b37231fe8766559036a 100644 (file)
@@ -25,6 +25,12 @@ runs:
     - name: install wait-for-it
       shell: bash
       run: sudo apt update && sudo apt-get -qq install wait-for-it
+    - name: Enable KVM group perms
+      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 --name-match=kvm
     - name: Start VM in background
       shell: bash
       run: |