-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/libvirtd: add option to run qemu as non-root #37281
Conversation
yes, there are some cases that require qemu to run as root. another one is passthrough file ownership and permission of 9p mounts. |
rebased and solved merge conflict |
@peterhoeg this contributes to #41092 and has been around for a while so I would like to see it merged for 18.09. Any thoughts? |
Does it work with |
No, |
Yes, one-time manual intervention ( If we believe it's more important to avoid manual intervention, we can merge this with We could also change the default to |
@volth good idea, thanks. So I'll change this PR to the non-breaking version and add the second one after this is merged. |
New option virtualisation.libvirtd.qemuRunAsRoot (default: true). If false, qemu is run as non-privileged user qemu-libvirtd, reducing security risk
The interactiosn between 9p/libvirt/qemu can be a real pain (dynamic_ownership being a false hope). After hours of fiddling the only configuration that worked for me to have the /nix/store owned by root while retaining the capaibily to share home folders with my VM was to mount these folders as mapped and run qemu as myself.
This PR prepends another user such that I have:
and apparently libvirtd only picks the first user since reverting the PR let my VM start contrary to the behavior with this PR:
|
Yes, that seems to be the case. A (somewhat non-intuitive) workaround for your config is to set |
To make this case more intuitive we could put the |
haha right but doesn't look like a long term solution. some other modules allows to specify user/group so that might be better ? |
Motivation for this change
In current NixOS,
libvirtd
runsqemu
processes as root by default. This increases security risk and is not necessary for most applications.Users can of course manually modify the user for qemu processes using the
virtualisation.libvirtd.qemuVerbatimConfig
option, but that is rather inconvenient.This change adds a new NixOS option
virtualisation.libvirtd.qemuRunAsRoot
.If false
(the default),qemu
is run as a non-privileged userqemu-libvirtd
.Other distros with a similar default behaviour include Debian, Arch and Fedora.
Edit: As per discussion below, this now implements a first step by adding the
qemuRunAsRoot
option but setting it tofalse
by default to avoid permission issues with existing guests.The plan is to change the default to
true
later in a separate PR to ease the transition.Things done
Manually tested.
/cc @fpletz @volth