]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
Qemu: add a group kvm to access /dev/kvm eaiser
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 17 Jun 2016 11:06:40 +0000 (13:06 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 20 Jun 2016 15:25:29 +0000 (16:25 +0100)
As a normal user, it is not possible to use qemu with KVM. This is bad
because it is better when it is possible to start the machine with a
less privileged user. To achieve this a group KVM is created and the
access to /dev/kvm is allowed for this group. So every user in this
group can use qemu with KVM.
This change is also useful for libvirt because the VMs can be started
with user nobody and group kvm.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/qemu/65-kvm.rules [new file with mode: 0644]
config/rootfiles/packages/qemu
lfs/qemu
src/paks/qemu/install.sh

diff --git a/config/qemu/65-kvm.rules b/config/qemu/65-kvm.rules
new file mode 100644 (file)
index 0000000..569ded9
--- /dev/null
@@ -0,0 +1,2 @@
+KERNEL=="kvm", GROUP="kvm", MODE="0660"
+KERNEL=="vhost-net", GROUP="kvm", MODE="0660", TAG+="uaccess", OPTIONS+="static_node=vhost-net"
index 482087b7b20688744cd1e53a6df0b855b8465dc5..3b3f3616daadf6e05a0c4e42c3c5c9d439ea0a25 100644 (file)
@@ -1,3 +1,4 @@
+lib/udev/rules.d/65-kvm.rules
 usr/bin/qemu
 usr/bin/qemu-arm
 usr/bin/qemu-ga
index 804ec269f629d968ece7feb4cf87b9bf36e46e76..c32953c9766118702134267dafe8732ae26a9a63 100644 (file)
--- a/lfs/qemu
+++ b/lfs/qemu
@@ -33,7 +33,7 @@ DIR_APP    = $(DIR_SRC)/$(THISAPP)
 TARGET     = $(DIR_INFO)/$(THISAPP)
 SUP_ARCH   = i586 x86_64
 PROG       = qemu
-PAK_VER    = 18
+PAK_VER    = 19
 
 DEPS       = "sdl spice"
 
@@ -95,6 +95,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        paxctl -m -r /usr/bin/qemu-arm
        paxctl -m -r /usr/bin/qemu-i386
        paxctl -m -r /usr/bin/qemu-x86_64
+       # install an udev script to set the permissions of /dev/kvm
+       cp -avf $(DIR_SRC)/config/qemu/65-kvm.rules /lib/udev/rules.d/65-kvm.rules
 
        @rm -rf $(DIR_APP)
        @$(POSTBUILD)
index a9f7321c0a4da626523fa27f1b537aecd7d484a5..e44ba5eca73b537ad2fac02b1d2301ef54b458ac 100644 (file)
@@ -22,6 +22,8 @@
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
+#create the group kvm when they not exist
+getent group kvm >/dev/null || groupadd kvm
 extract_files
 restore_backup ${NAME}
 echo shm       /dev/shm        tmpfs   defaults,size=256M      0       0 >> /etc/fstab