]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
action: Allow unprivileged access to kvm, vhost-vsock and vhost-net devices
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 11 May 2023 08:55:18 +0000 (10:55 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 11 May 2023 11:37:28 +0000 (13:37 +0200)
These are restricted on Debian/Ubuntu but we want to allow running
unprivileged qemu so let's loosen the permissions on these devices
to make that possible.

action.yaml

index f4675781b5ddd381d0c2b58d071109e4ecafafb9..738fe364671088474e6d6603a4c1c0bb20b66ad3 100644 (file)
@@ -5,6 +5,22 @@ runs:
   using: composite
   steps:
 
+  - name: Permit unprivileged access to kvm, vhost-vsock and vhost-net devices
+    shell: bash
+    run: |
+      sudo adduser $(id -un) kvm
+      sudo sed -i '/kvm/s/0660/0666/g'   /usr/lib/tmpfiles.d/static-nodes-permissions.conf
+      sudo sed -i '/vhost/s/0660/0666/g' /usr/lib/tmpfiles.d/static-nodes-permissions.conf
+      sudo modprobe kvm
+      sudo modprobe vhost_vsock
+      sudo modprobe vhost_net
+      [[ -e /dev/kvm ]] && sudo chmod 666 /dev/kvm
+      sudo chmod 666 /dev/vhost-vsock
+      sudo chmod 666 /dev/vhost-net
+      lsmod
+      [[ -e /dev/kvm ]] && ls -l /dev/kvm
+      ls -l /dev/vhost-*
+
   - name: Dependencies
     shell: bash
     run: |