Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 596168 - Add group for KVM and add udev rule
Summary: Add group for KVM and add udev rule
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-04 16:40 UTC by William L. Thomson Jr.
Modified: 2018-06-10 03:53 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William L. Thomson Jr. 2016-10-04 16:40:57 UTC
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.
Comment 1 Ben Kohler gentoo-dev 2016-10-04 16:46:41 UTC
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
Comment 2 William L. Thomson Jr. 2016-10-04 19:05:01 UTC
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 :)
Comment 3 Mike Gilbert gentoo-dev 2016-10-04 21:31:55 UTC
(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.
Comment 4 Mike Gilbert gentoo-dev 2016-10-04 21:34:44 UTC
(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.
Comment 5 Matthias Maier gentoo-dev 2016-10-04 22:28:15 UTC
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.
Comment 6 Matthias Maier gentoo-dev 2016-10-04 22:29:14 UTC
(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.
Comment 7 Matthias Maier gentoo-dev 2016-10-04 22:29:30 UTC
> Excuse me, it is 64-kvm.rules.

65-kvm.rules ...