Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 477524 - app-emulation/libvirt systemd units use /etc/sysconfig
Summary: app-emulation/libvirt systemd units use /etc/sysconfig
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-20 17:36 UTC by Justin Lecher (RETIRED)
Modified: 2014-11-03 01:39 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 Justin Lecher (RETIRED) gentoo-dev 2013-07-20 17:36:27 UTC
[Service]
EnvironmentFile=-/etc/sysconfig/libvirtd
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-07-20 17:41:24 UTC
/etc/conf.d is even more invalid.
Comment 2 Pacho Ramos gentoo-dev 2013-07-20 18:37:15 UTC
(In reply to Michał Górny from comment #1)
> /etc/conf.d is even more invalid.

But I guess that it's what we should use in Gentoo, no? :/ What would be the alternative then?
Comment 3 Matthias Maier gentoo-dev 2014-10-21 18:21:27 UTC
The proper location for systemd specific configuration files is
  /etc/systemd/system/libvirtd.service.d,
etc.
Comment 4 Richard Freeman gentoo-dev 2014-10-21 18:42:28 UTC
(In reply to Matthias Maier from comment #3)
> The proper location for systemd specific configuration files is
>   /etc/systemd/system/libvirtd.service.d,
> etc.

Do we really want ebuilds sticking files in here?  This should just be for user-provided configuration overrides.  

Also, I don't think that this is where we want things like environment files, is it?
Comment 5 Justin Lecher (RETIRED) gentoo-dev 2014-10-22 08:46:32 UTC
(In reply to Richard Freeman from comment #4)
> Also, I don't think that this is where we want things like environment
> files, is it?

No, we need some other palce in /etc
Comment 6 Pacho Ramos gentoo-dev 2014-10-22 08:58:17 UTC
The policy about where to place config files (if really needed) is at:
https://wiki.gentoo.org/wiki/Project:Systemd/Ebuild_policy#Unit_file_guidelines

If you don't need any config file, no problem, even keeping:
EnvironmentFile=-/etc/sysconfig/libvirtd

as it won't try to load that file if not present (due the "-")
Comment 7 Richard Freeman gentoo-dev 2014-10-22 12:16:24 UTC
(In reply to Pacho Ramos from comment #6)
> The policy about where to place config files (if really needed) is at:
> https://wiki.gentoo.org/wiki/Project:Systemd/
> Ebuild_policy#Unit_file_guidelines
> 
> If you don't need any config file, no problem, even keeping:
> EnvironmentFile=-/etc/sysconfig/libvirtd
> 
> as it won't try to load that file if not present (due the "-")

Ugh - I don't particularly like having packages stick stuff in /etc/systemd/system, but I suppose if every line is commented out it isn't the end of the world.  I can just ignore that file and make my changes in an entirely different one.  :)

Apologies - I realize this isn't an issue for libvirt.
Comment 8 Matthias Maier gentoo-dev 2014-10-31 06:33:57 UTC
So, there is

net-misc/ntp
  /etc/systemd/system/sntp.service.d/00gentoo.conf
  /etc/systemd/system/ntpdate.service.d/00gentoo.conf

net-misc/dhcp
  /etc/systemd/system/dhcrelay6.service.d/00gentoo.conf
  /etc/systemd/system/dhcrelay4.service.d/00gentoo.conf

and the systemd.eclass has systemd_install_serviced (for installing exactly this file) which is used by half a dozen of packages.

And we're talking about /etc/sysconfig/libvirtd overriding Environment attributes, so it would nicely fit in.

But this ultimately a question of policy... so, how to proceed?

($ rm -r /etc/sysconfig is hardly an option because on looses the file explaining what one can configure...)
Comment 9 Pacho Ramos gentoo-dev 2014-10-31 09:31:15 UTC
as I have seen, upstream is providing that /etc/sysconfig/libvirtd and the systemd unit files using it. Personally, I would prefer to keep it as that way upstream will completely support us (well, if some problem arises with service activation, they will need to hear us as we do all in upstream way)... but maybe you should wait for other systemd team members opinions :/
Comment 10 Mike Gilbert gentoo-dev 2014-10-31 14:28:34 UTC
(In reply to Pacho Ramos from comment #9)

I'm guessing that upstream happens to be a Fedora project? That would explain the use of /etc/sysconfig.

We don't generally utilize that directory on Gentoo, and I don't think we should start now.
Comment 11 Pacho Ramos gentoo-dev 2014-10-31 14:44:24 UTC
The problem is that upstream systemd looks to not define any directory to place that config files and, since Fedora, Arch, Mandriva/Mageia and openSuSE tend to use /etc/sysconfig... I don't know if this has been discussed at any time in systemd upstream side as current situation is so inconsistent... :|
Comment 12 Richard Freeman gentoo-dev 2014-10-31 15:04:17 UTC
I think a big question is whether it makes more sense to use the Gentoo config directory which isn't going to align with upstream units, or put systemd configs in a directory most upstreams use.

I think the latter makes sense since this creates the possibility of cross-distro configs.
Comment 13 Pacho Ramos gentoo-dev 2014-10-31 15:19:08 UTC
After reading again all the involved files, I change my opinion and I think we should use the same as we do for ntp and others if really needed to pass other options to libvirt. 

The reasons for changing my opinion on this concrete issue are that upstream is simply relying on /etc/sysconfig/libvirtd for LIBVIRTD_ARGS variable. All the other variables will simply be ignored (I guess they are still there for historical reasons).

Then:
- Does libvirt really need to let people play appending more options to it using LIBVIRTD_ARGS?
- In that case it can use a file with something like:
[Service]
Environment="LIBVIRTD_ARGS="

And you don't need to ever touch provided unit files
Comment 14 Alexander Tsoy 2014-10-31 15:22:51 UTC
(In reply to Pacho Ramos from comment #13)

> - Does libvirt really need to let people play appending more options to it
> using LIBVIRTD_ARGS?

AFAIK, the only way to make libvirtd listen on TCP port is to pass "--listen" option to it.
Comment 15 Matthias Maier gentoo-dev 2014-10-31 15:45:54 UTC
I should have inspected the actual content of the files earlier :-/

- passing options to libvirtd is actually unnecessary. --listen is only a safeguard to _allow_ configuration of network sockets (via listen_tls and listen_tcp in /etc/libvirt/libvirtd.conf) *)
- The rest is very esoteric and could be safely removed. (Or a 00gentoo.conf stub could be provided).


- virtlockd does not need any user supplied configuration options either. (Otherwise overriding the service file is the better approach)


So, only libvirt-guests.service remains that needs two configuration options via environment (and the policy issue discussed here remains valid for the location of those).


*) Just always passing --listen to the libvirtd is a subtle change, though. We would have to make sure that (a) all user configuration is updated to set above options in /etc/libvirt/libvirtd.conf - otherwise we would open up an immediate security issue.
Comment 16 Pacho Ramos gentoo-dev 2014-10-31 15:49:50 UTC
(In reply to Matthias Maier from comment #15)
[...[
> So, only libvirt-guests.service remains that needs two configuration options
> via environment (and the policy issue discussed here remains valid for the
> location of those).
[...]

Reading that file, looks like variables are not used directly by the unit, instead, I guess /usr/libexec/libvirt-guests.sh should be getting the needed variables from relevant file by itself. And that file could be placed in a "more general" place, I mean, something like /etc/yourprogram.conf (libvirt-guests.conf in the directory where general libvirt stuff is configure even for people running it manually?)
Comment 17 Matthias Maier gentoo-dev 2014-10-31 16:04:01 UTC
Good point, a closer look at libvirt-guests.sh reveals that this very redhat centric piece of code already needs some further adjustment. I'll phase out /etc/sysconfig in an -r1 along with some further fixups (unrelated bugs).
Specifically:

- I'll drop a short (completely commented) file into /etc/systemd/system/libvirt.d/00gentoo.conf with something like "for libvirtd listening on TCP/IP connections, uncomment the following lines". (I really do not want to touch this default behavior - this just asks for trouble.)

- remove /etc/sysconfig/virtlockd entirely - no point for this file,

- refactor libvirt-guests.sh to use configuration in /etc/libvirtd/libvirt-guests.conf (and hope for upstream removing it soon),

- provide an elog notification that explains this change.

Does this sound good?
Comment 18 Pacho Ramos gentoo-dev 2014-10-31 16:19:53 UTC
Sounds fine to me :)
Comment 19 Richard Freeman gentoo-dev 2014-10-31 16:44:37 UTC
(In reply to Matthias Maier from comment #17)

> - I'll drop a short (completely commented) file into
> /etc/systemd/system/libvirt.d/00gentoo.conf with something like "for
> libvirtd listening on TCP/IP connections, uncomment the following lines". (I
> really do not want to touch this default behavior - this just asks for
> trouble.)

This seems like a good idea - set ENVIRONMENT in an add-in.  I actually have one or two of my own unit files that I can convert in this manner and submit them for other packages (replacing conf.d was the only thing missing).
Comment 20 Matthias Maier gentoo-dev 2014-11-03 01:39:47 UTC
Starting with version 1.2.9-r1, /etc/sysconfig is gone.


  03 Nov 2014; Matthias Maier <tamiko@gentoo.org> libvirt-1.2.9-r1.ebuild:
  fix typo, print elog message when replacing...

*libvirt-1.2.9-r1 (03 Nov 2014)

  03 Nov 2014; Matthias Maier <tamiko@gentoo.org>
  +files/libvirt-1.2.9-do_not_use_sysconf.patch, +files/libvirtd.service.conf,
  +libvirt-1.2.9-r1.ebuild, -files/libvirt-1.2.6-numa.patch,
  libvirt-9999.ebuild, metadata.xml:
  add wireshark-plugins use flag, bug 508340; do not install into runtime paths,
  bug 520408; do not install into units use /etc/sysconfig, bug 477524