Some packages like Android Studio and its emulator need user access to /dev/kvm. At this time on Gentoo it ends up 600, user/group root. I was in the process of creating a udev rule for Android Studio. When I realized that is not the best approach. I am not sure what package should be modified, maybe a meta package? Or use flag for udev not sure. We need 2 things; 1. A group for kvm. Not sure what package should provide that. 2. A udev rule for kvm. Such as KERNEL=="kvm", NAME="%k", GROUP="kvm", MODE="0660" That will allow users to add themselves to the kvm group. Rather than 0666 for /dev/kvm with user/group being root as it is now. Which will work Android Studio and anything else the user may run that needs access to /dev/kvm. Providing they add themselves to the kvm group. The rule can go with udev, but not sure about the user creation. I guess if it is controlled via use flag with udev, then udev can create the user group. KVM comes from the kernel so not sure any other package would make sense. I do not think it would make sense to provide the udev rule with the kernel, nor create the group. But it could be done any which way really.
There may be a better way to handle this but fwiw, app-emulation/qemu already supplies /lib/udev/rules.d/65-kvm.rules which does: KERNEL=="kvm", GROUP="kvm", MODE="0660" Maybe a common kvm-stuff-for-userland package could provide it for everybody
I went with a kvm use flag for udev. Creating another package may be a way to go, but it is just for creation of a group and installing a rule file. Not sure that is worth an entire ebuild. Walues for HOMEPAGE, SRC_URI would not be needed or license. So it would be an odd ebuild, though likely possible. Plus any packages would need to be updated and have their dependencies changed. Granted with this change, that would still need to occur, but just in adding udev as a dep with the USE flag enabled. It could go either way I guess. I think adding to udev is the simplest approach. No one would question udev installing/owning rule files. The question really is the group, bit odd to have udev create that, but its very minor stuff. I created this pull request with my changes. Granted app-emulation/qemu package will need to be changed. Though conflict is not to likely without users doing that, setting both kvm and linux_kernel use flags, neither being global. https://github.com/gentoo/gentoo/pull/2475 I will likely just go with how others want to commit this to tree. It does not matter to me. I just need /dev/kvm under a group I can add users to :)
(In reply to William L. Thomson Jr. from comment #2) > I went with a kvm use flag for udev. What about systemd and eudev? udev seems like the wrong place for this.
(In reply to Mike Gilbert from comment #3) > udev seems like the wrong place for this. I should amend that: If we can get the systemd people to add a rule like this upstream, that would make sense. If we are going for a distro-specific rule, I think a separate package makes more sense.
app-emulation/qemu for a long time already installs the following file: /lib/udev/rules.d/64-kvm.rules: KERNEL=="kvm", GROUP="kvm", MODE="0660" and creates a kvm group: pkg_setup() { enewgroup kvm } This kvm group is for example used by kvm (that creates a custom "qemu" user for the qemu hypervisor). So, what about simply refactoring above in an independent package? I ask that all related changes are coordinated with the virtualization project, and the qemu subproject in particular.
(In reply to Matthias Maier from comment #5) > app-emulation/qemu for a long time already installs the following file: > > /lib/udev/rules.d/64-kvm.rules: ~~~~~~~~~~~~ Excuse me, it is 64-kvm.rules.
> Excuse me, it is 64-kvm.rules. 65-kvm.rules ...