[libvirt PATCH 0/5] meson: Introduce initconfdir option

Makes things nicer for those using distros that are not derived from RHEL or SUSE. Andrea Bolognani (5): meson: Introduce initconfdir option meson: Use initconfdir rpm: Set initconfdir explicitly meson: Move definition of os_release meson: Improve initconfdir defaults docs/manpages/libvirt-guests.rst | 2 +- docs/manpages/meson.build | 1 + libvirt.spec.in | 1 + meson.build | 20 +++++++++++++++++++- meson_options.txt | 1 + src/ch/virtchd.service.in | 2 +- src/interface/virtinterfaced.service.in | 2 +- src/libxl/virtxend.service.in | 2 +- src/locking/virtlockd.service.in | 2 +- src/logging/virtlogd.service.in | 2 +- src/lxc/virtlxcd.service.in | 2 +- src/meson.build | 1 + src/network/virtnetworkd.service.in | 2 +- src/node_device/virtnodedevd.service.in | 2 +- src/nwfilter/virtnwfilterd.service.in | 2 +- src/qemu/virtqemud.service.in | 2 +- src/remote/libvirtd.service.in | 2 +- src/remote/virtproxyd.service.in | 2 +- src/secret/virtsecretd.service.in | 2 +- src/storage/virtstoraged.service.in | 2 +- src/vbox/virtvboxd.service.in | 2 +- src/vz/virtvzd.service.in | 2 +- tools/libvirt-guests.service.in | 2 +- tools/libvirt-guests.sh.in | 5 +++-- tools/meson.build | 1 + tools/virt-pki-validate.in | 13 +++++++------ 26 files changed, 52 insertions(+), 27 deletions(-) -- 2.40.1

Right now we expect the configuration files for init scripts to live in /etc/sysconfig, but that location is only used by RHEL- and SUSE-derived distros. This means that packagers for other distros have to patch things as part of the build process, while people building from source will get wonky integration. This new option will provide a convenient way to override the default location at build time that is usable by distro packagers and people building from source alike. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 5 +++++ meson_options.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/meson.build b/meson.build index bad13c0c9d..8da987b1cb 100644 --- a/meson.build +++ b/meson.build @@ -76,6 +76,11 @@ if runstatedir == '' runstatedir = localstatedir / 'run' endif +initconfdir = get_option('initconfdir') +if initconfdir == '' + initconfdir = sysconfdir / 'sysconfig' +endif + bindir = prefix / get_option('bindir') datadir = prefix / get_option('datadir') includedir = prefix / get_option('includedir') diff --git a/meson_options.txt b/meson_options.txt index 861c5577d2..9174c4021c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,6 +3,7 @@ option('packager', type: 'string', value: '', description: 'Extra packager name' option('packager_version', type: 'string', value: '', description: 'Extra packager version') option('system', type: 'boolean', value: false, description: 'Set install paths to system ones') option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc') +option('initconfdir', type: 'string', value: '', description: 'directory for init script configuration files') option('expensive_tests', type: 'feature', value: 'auto', description: 'set the default for enabling expensive tests (long timeouts)') option('test_coverage', type: 'boolean', value: false, description: 'turn on code coverage instrumentation') option('git_werror', type: 'feature', value: 'auto', description: 'use -Werror if building from GIT') -- 2.40.1

On Tue, May 02, 2023 at 07:15:48PM +0200, Andrea Bolognani wrote:
Right now we expect the configuration files for init scripts to live in /etc/sysconfig, but that location is only used by RHEL- and SUSE-derived distros.
This means that packagers for other distros have to patch things as part of the build process, while people building from source will get wonky integration.
This new option will provide a convenient way to override the default location at build time that is usable by distro packagers and people building from source alike.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/manpages/libvirt-guests.rst | 2 +- docs/manpages/meson.build | 1 + src/ch/virtchd.service.in | 2 +- src/interface/virtinterfaced.service.in | 2 +- src/libxl/virtxend.service.in | 2 +- src/locking/virtlockd.service.in | 2 +- src/logging/virtlogd.service.in | 2 +- src/lxc/virtlxcd.service.in | 2 +- src/meson.build | 1 + src/network/virtnetworkd.service.in | 2 +- src/node_device/virtnodedevd.service.in | 2 +- src/nwfilter/virtnwfilterd.service.in | 2 +- src/qemu/virtqemud.service.in | 2 +- src/remote/libvirtd.service.in | 2 +- src/remote/virtproxyd.service.in | 2 +- src/secret/virtsecretd.service.in | 2 +- src/storage/virtstoraged.service.in | 2 +- src/vbox/virtvboxd.service.in | 2 +- src/vz/virtvzd.service.in | 2 +- tools/libvirt-guests.service.in | 2 +- tools/libvirt-guests.sh.in | 5 +++-- tools/meson.build | 1 + tools/virt-pki-validate.in | 13 +++++++------ 23 files changed, 31 insertions(+), 26 deletions(-) diff --git a/docs/manpages/libvirt-guests.rst b/docs/manpages/libvirt-guests.rst index bea08e3bff..f27eaad6e4 100644 --- a/docs/manpages/libvirt-guests.rst +++ b/docs/manpages/libvirt-guests.rst @@ -42,7 +42,7 @@ FILES ``libvirt-guests`` defines several variables to control service behavior. The default value of these variables can be overridden in: -* ``@SYSCONFDIR@/sysconfig/libvirt-guests`` +* ``@INITCONFDIR@/libvirt-guests`` The following variables are supported: diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build index afcadaefbd..bdc17011a8 100644 --- a/docs/manpages/meson.build +++ b/docs/manpages/meson.build @@ -88,6 +88,7 @@ endforeach docs_man_conf = configuration_data({ 'SYSCONFDIR': sysconfdir, 'RUNSTATEDIR': runstatedir, + 'INITCONFDIR': initconfdir, 'VERSION': meson.project_version(), }) diff --git a/src/ch/virtchd.service.in b/src/ch/virtchd.service.in index 8c22b02c9e..a07c04a845 100644 --- a/src/ch/virtchd.service.in +++ b/src/ch/virtchd.service.in @@ -18,7 +18,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTCHD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtchd +EnvironmentFile=-@initconfdir@/virtchd ExecStart=@sbindir@/virtchd $VIRTCHD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/interface/virtinterfaced.service.in b/src/interface/virtinterfaced.service.in index cb860ff1c4..1be3ab32dc 100644 --- a/src/interface/virtinterfaced.service.in +++ b/src/interface/virtinterfaced.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTINTERFACED_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtinterfaced +EnvironmentFile=-@initconfdir@/virtinterfaced ExecStart=@sbindir@/virtinterfaced $VIRTINTERFACED_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/libxl/virtxend.service.in b/src/libxl/virtxend.service.in index 9171d4fdf8..abb1972777 100644 --- a/src/libxl/virtxend.service.in +++ b/src/libxl/virtxend.service.in @@ -19,7 +19,7 @@ ConditionPathExists=/proc/xen/capabilities [Service] Type=notify Environment=VIRTXEND_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtxend +EnvironmentFile=-@initconfdir@/virtxend ExecStart=@sbindir@/virtxend $VIRTXEND_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in index 19271d1e7d..23054369d5 100644 --- a/src/locking/virtlockd.service.in +++ b/src/locking/virtlockd.service.in @@ -8,7 +8,7 @@ Documentation=https://libvirt.org [Service] Environment=VIRTLOCKD_ARGS= -EnvironmentFile=-@sysconfdir@/sysconfig/virtlockd +EnvironmentFile=-@initconfdir@/virtlockd ExecStart=@sbindir@/virtlockd $VIRTLOCKD_ARGS ExecReload=/bin/kill -USR1 $MAINPID # Losing the locks is a really bad thing that will diff --git a/src/logging/virtlogd.service.in b/src/logging/virtlogd.service.in index 8ab5478517..158124e4d3 100644 --- a/src/logging/virtlogd.service.in +++ b/src/logging/virtlogd.service.in @@ -7,7 +7,7 @@ Documentation=man:virtlogd(8) Documentation=https://libvirt.org [Service] -EnvironmentFile=-@sysconfdir@/sysconfig/virtlogd +EnvironmentFile=-@initconfdir@/virtlogd ExecStart=@sbindir@/virtlogd $VIRTLOGD_ARGS ExecReload=/bin/kill -USR1 $MAINPID # Losing the logs is a really bad thing that will diff --git a/src/lxc/virtlxcd.service.in b/src/lxc/virtlxcd.service.in index 9946db9462..2623f7375a 100644 --- a/src/lxc/virtlxcd.service.in +++ b/src/lxc/virtlxcd.service.in @@ -18,7 +18,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTLXCD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtlxcd +EnvironmentFile=-@initconfdir@/virtlxcd ExecStart=@sbindir@/virtlxcd $VIRTLXCD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/meson.build b/src/meson.build index ad7796f03d..c2b882d464 100644 --- a/src/meson.build +++ b/src/meson.build @@ -808,6 +808,7 @@ if conf.has('WITH_LIBVIRTD') 'runstatedir': runstatedir, 'sbindir': sbindir, 'sysconfdir': sysconfdir, + 'initconfdir': initconfdir, 'name': unit['name'], 'service': unit['service'], 'sockprefix': unit['sockprefix'], diff --git a/src/network/virtnetworkd.service.in b/src/network/virtnetworkd.service.in index 05ce672b73..48423e777d 100644 --- a/src/network/virtnetworkd.service.in +++ b/src/network/virtnetworkd.service.in @@ -17,7 +17,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNETWORKD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnetworkd +EnvironmentFile=-@initconfdir@/virtnetworkd ExecStart=@sbindir@/virtnetworkd $VIRTNETWORKD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/node_device/virtnodedevd.service.in b/src/node_device/virtnodedevd.service.in index cd9de362fd..3ceed30f29 100644 --- a/src/node_device/virtnodedevd.service.in +++ b/src/node_device/virtnodedevd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNODEDEVD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnodedevd +EnvironmentFile=-@initconfdir@/virtnodedevd ExecStart=@sbindir@/virtnodedevd $VIRTNODEDEVD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/nwfilter/virtnwfilterd.service.in b/src/nwfilter/virtnwfilterd.service.in index ab65419e0c..37fa54d684 100644 --- a/src/nwfilter/virtnwfilterd.service.in +++ b/src/nwfilter/virtnwfilterd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNWFILTERD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnwfilterd +EnvironmentFile=-@initconfdir@/virtnwfilterd ExecStart=@sbindir@/virtnwfilterd $VIRTNWFILTERD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in index 315359e287..032cbcbbf0 100644 --- a/src/qemu/virtqemud.service.in +++ b/src/qemu/virtqemud.service.in @@ -20,7 +20,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTQEMUD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtqemud +EnvironmentFile=-@initconfdir@/virtqemud ExecStart=@sbindir@/virtqemud $VIRTQEMUD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in index 30588279f8..11507207a1 100644 --- a/src/remote/libvirtd.service.in +++ b/src/remote/libvirtd.service.in @@ -28,7 +28,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=LIBVIRTD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/libvirtd +EnvironmentFile=-@initconfdir@/libvirtd ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/remote/virtproxyd.service.in b/src/remote/virtproxyd.service.in index f9bb6b84a9..dd3bdf3429 100644 --- a/src/remote/virtproxyd.service.in +++ b/src/remote/virtproxyd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTPROXYD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtproxyd +EnvironmentFile=-@initconfdir@/virtproxyd ExecStart=@sbindir@/virtproxyd $VIRTPROXYD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/secret/virtsecretd.service.in b/src/secret/virtsecretd.service.in index 6d298c5334..774cfc3ecd 100644 --- a/src/secret/virtsecretd.service.in +++ b/src/secret/virtsecretd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTSECRETD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtsecretd +EnvironmentFile=-@initconfdir@/virtsecretd ExecStart=@sbindir@/virtsecretd $VIRTSECRETD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/storage/virtstoraged.service.in b/src/storage/virtstoraged.service.in index eda4d86d37..e1a1ea6820 100644 --- a/src/storage/virtstoraged.service.in +++ b/src/storage/virtstoraged.service.in @@ -16,7 +16,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTSTORAGED_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtstoraged +EnvironmentFile=-@initconfdir@/virtstoraged ExecStart=@sbindir@/virtstoraged $VIRTSTORAGED_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/vbox/virtvboxd.service.in b/src/vbox/virtvboxd.service.in index 6f447276e9..e73206591a 100644 --- a/src/vbox/virtvboxd.service.in +++ b/src/vbox/virtvboxd.service.in @@ -15,7 +15,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTVBOXD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtvboxd +EnvironmentFile=-@initconfdir@/virtvboxd ExecStart=@sbindir@/virtvboxd $VIRTVBOXD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/vz/virtvzd.service.in b/src/vz/virtvzd.service.in index 2b1165c92b..bd98d96262 100644 --- a/src/vz/virtvzd.service.in +++ b/src/vz/virtvzd.service.in @@ -15,7 +15,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTVZD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtvzd +EnvironmentFile=-@initconfdir@/virtvzd ExecStart=@sbindir@/virtvzd $VIRTVZD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in index 1c569c320d..c547218f2a 100644 --- a/tools/libvirt-guests.service.in +++ b/tools/libvirt-guests.service.in @@ -14,7 +14,7 @@ Documentation=man:libvirt-guests(8) Documentation=https://libvirt.org [Service] -EnvironmentFile=-@sysconfdir@/sysconfig/libvirt-guests +EnvironmentFile=-@initconfdir@/libvirt-guests # Hack just call traditional service until we factor # out the code ExecStart=@libexecdir@/libvirt-guests.sh start diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 87f96af14d..016014215f 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -18,6 +18,7 @@ sysconfdir="@sysconfdir@" localstatedir="@localstatedir@" +initconfdir="@initconfdir@" libvirtd="@sbindir@"/libvirtd # Source function library. @@ -39,8 +40,8 @@ START_DELAY=0 BYPASS_CACHE=0 SYNC_TIME=0 -test -f "$sysconfdir"/sysconfig/libvirt-guests && - . "$sysconfdir"/sysconfig/libvirt-guests +test -f "$initconfdir"/libvirt-guests && + . "$initconfdir"/libvirt-guests LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests diff --git a/tools/meson.build b/tools/meson.build index fad7f202ad..f2d58cfdcb 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -241,6 +241,7 @@ tools_conf = configuration_data({ 'sbindir': sbindir, 'schemadir': pkgdatadir / 'schemas', 'sysconfdir': sysconfdir, + 'initconfdir': initconfdir, }) configure_file( diff --git a/tools/virt-pki-validate.in b/tools/virt-pki-validate.in index 7100eafb63..c91f247ba5 100644 --- a/tools/virt-pki-validate.in +++ b/tools/virt-pki-validate.in @@ -73,6 +73,7 @@ echo Found "$CERTOOL" # SYSCONFDIR="@sysconfdir@" PKI="$SYSCONFDIR/pki" +INITCONFDIR="@initconfdir@" if [ ! -d "$PKI" ] then echo the $PKI directory is missing, it is usually @@ -294,24 +295,24 @@ fi if [ "$SERVER" = "1" ] then - if [ -r "$SYSCONFDIR"/sysconfig/libvirtd ] + if [ -r "$INITCONFDIR"/libvirtd ] then - if grep "^LIBVIRTD_ARGS.*--listen" "$SYSCONFDIR"/sysconfig/libvirtd \ + if grep "^LIBVIRTD_ARGS.*--listen" "$INITCONFDIR"/libvirtd \ >/dev/null 2>&1 then : else - echo Make sure "$SYSCONFDIR"/sysconfig/libvirtd is setup to listen to + echo Make sure "$INITCONFDIR"/libvirtd is setup to listen to echo TCP/IP connections and restart the libvirtd service fi fi - if [ -r "$SYSCONFDIR"/sysconfig/iptables ] + if [ -r "$INITCONFDIR"/iptables ] then - if grep "$PORT" "$SYSCONFDIR"/sysconfig/iptables >/dev/null 2>&1 + if grep "$PORT" "$INITCONFDIR"/iptables >/dev/null 2>&1 then : else - echo Make sure "$SYSCONFDIR"/sysconfig/iptables is setup to allow + echo Make sure "$INITCONFDIR"/iptables is setup to allow echo incoming TCP/IP connections on port $PORT and echo restart the iptables service fi -- 2.40.1

On Tue, May 02, 2023 at 07:15:49PM +0200, Andrea Bolognani wrote:
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- docs/manpages/libvirt-guests.rst | 2 +- docs/manpages/meson.build | 1 + src/ch/virtchd.service.in | 2 +- src/interface/virtinterfaced.service.in | 2 +- src/libxl/virtxend.service.in | 2 +- src/locking/virtlockd.service.in | 2 +- src/logging/virtlogd.service.in | 2 +- src/lxc/virtlxcd.service.in | 2 +- src/meson.build | 1 + src/network/virtnetworkd.service.in | 2 +- src/node_device/virtnodedevd.service.in | 2 +- src/nwfilter/virtnwfilterd.service.in | 2 +- src/qemu/virtqemud.service.in | 2 +- src/remote/libvirtd.service.in | 2 +- src/remote/virtproxyd.service.in | 2 +- src/secret/virtsecretd.service.in | 2 +- src/storage/virtstoraged.service.in | 2 +- src/vbox/virtvboxd.service.in | 2 +- src/vz/virtvzd.service.in | 2 +- tools/libvirt-guests.service.in | 2 +- tools/libvirt-guests.sh.in | 5 +++-- tools/meson.build | 1 + tools/virt-pki-validate.in | 13 +++++++------ 23 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/docs/manpages/libvirt-guests.rst b/docs/manpages/libvirt-guests.rst index bea08e3bff..f27eaad6e4 100644 --- a/docs/manpages/libvirt-guests.rst +++ b/docs/manpages/libvirt-guests.rst @@ -42,7 +42,7 @@ FILES ``libvirt-guests`` defines several variables to control service behavior. The default value of these variables can be overridden in:
-* ``@SYSCONFDIR@/sysconfig/libvirt-guests`` +* ``@INITCONFDIR@/libvirt-guests``
The following variables are supported:
diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build index afcadaefbd..bdc17011a8 100644 --- a/docs/manpages/meson.build +++ b/docs/manpages/meson.build @@ -88,6 +88,7 @@ endforeach docs_man_conf = configuration_data({ 'SYSCONFDIR': sysconfdir, 'RUNSTATEDIR': runstatedir, + 'INITCONFDIR': initconfdir, 'VERSION': meson.project_version(), })
diff --git a/src/ch/virtchd.service.in b/src/ch/virtchd.service.in index 8c22b02c9e..a07c04a845 100644 --- a/src/ch/virtchd.service.in +++ b/src/ch/virtchd.service.in @@ -18,7 +18,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTCHD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtchd +EnvironmentFile=-@initconfdir@/virtchd ExecStart=@sbindir@/virtchd $VIRTCHD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/interface/virtinterfaced.service.in b/src/interface/virtinterfaced.service.in index cb860ff1c4..1be3ab32dc 100644 --- a/src/interface/virtinterfaced.service.in +++ b/src/interface/virtinterfaced.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTINTERFACED_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtinterfaced +EnvironmentFile=-@initconfdir@/virtinterfaced ExecStart=@sbindir@/virtinterfaced $VIRTINTERFACED_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/libxl/virtxend.service.in b/src/libxl/virtxend.service.in index 9171d4fdf8..abb1972777 100644 --- a/src/libxl/virtxend.service.in +++ b/src/libxl/virtxend.service.in @@ -19,7 +19,7 @@ ConditionPathExists=/proc/xen/capabilities [Service] Type=notify Environment=VIRTXEND_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtxend +EnvironmentFile=-@initconfdir@/virtxend ExecStart=@sbindir@/virtxend $VIRTXEND_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in index 19271d1e7d..23054369d5 100644 --- a/src/locking/virtlockd.service.in +++ b/src/locking/virtlockd.service.in @@ -8,7 +8,7 @@ Documentation=https://libvirt.org
[Service] Environment=VIRTLOCKD_ARGS= -EnvironmentFile=-@sysconfdir@/sysconfig/virtlockd +EnvironmentFile=-@initconfdir@/virtlockd ExecStart=@sbindir@/virtlockd $VIRTLOCKD_ARGS ExecReload=/bin/kill -USR1 $MAINPID # Losing the locks is a really bad thing that will diff --git a/src/logging/virtlogd.service.in b/src/logging/virtlogd.service.in index 8ab5478517..158124e4d3 100644 --- a/src/logging/virtlogd.service.in +++ b/src/logging/virtlogd.service.in @@ -7,7 +7,7 @@ Documentation=man:virtlogd(8) Documentation=https://libvirt.org
[Service] -EnvironmentFile=-@sysconfdir@/sysconfig/virtlogd +EnvironmentFile=-@initconfdir@/virtlogd ExecStart=@sbindir@/virtlogd $VIRTLOGD_ARGS ExecReload=/bin/kill -USR1 $MAINPID # Losing the logs is a really bad thing that will diff --git a/src/lxc/virtlxcd.service.in b/src/lxc/virtlxcd.service.in index 9946db9462..2623f7375a 100644 --- a/src/lxc/virtlxcd.service.in +++ b/src/lxc/virtlxcd.service.in @@ -18,7 +18,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTLXCD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtlxcd +EnvironmentFile=-@initconfdir@/virtlxcd ExecStart=@sbindir@/virtlxcd $VIRTLXCD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/meson.build b/src/meson.build index ad7796f03d..c2b882d464 100644 --- a/src/meson.build +++ b/src/meson.build @@ -808,6 +808,7 @@ if conf.has('WITH_LIBVIRTD') 'runstatedir': runstatedir, 'sbindir': sbindir, 'sysconfdir': sysconfdir, + 'initconfdir': initconfdir, 'name': unit['name'], 'service': unit['service'], 'sockprefix': unit['sockprefix'], diff --git a/src/network/virtnetworkd.service.in b/src/network/virtnetworkd.service.in index 05ce672b73..48423e777d 100644 --- a/src/network/virtnetworkd.service.in +++ b/src/network/virtnetworkd.service.in @@ -17,7 +17,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNETWORKD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnetworkd +EnvironmentFile=-@initconfdir@/virtnetworkd ExecStart=@sbindir@/virtnetworkd $VIRTNETWORKD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/node_device/virtnodedevd.service.in b/src/node_device/virtnodedevd.service.in index cd9de362fd..3ceed30f29 100644 --- a/src/node_device/virtnodedevd.service.in +++ b/src/node_device/virtnodedevd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNODEDEVD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnodedevd +EnvironmentFile=-@initconfdir@/virtnodedevd ExecStart=@sbindir@/virtnodedevd $VIRTNODEDEVD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/nwfilter/virtnwfilterd.service.in b/src/nwfilter/virtnwfilterd.service.in index ab65419e0c..37fa54d684 100644 --- a/src/nwfilter/virtnwfilterd.service.in +++ b/src/nwfilter/virtnwfilterd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTNWFILTERD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtnwfilterd +EnvironmentFile=-@initconfdir@/virtnwfilterd ExecStart=@sbindir@/virtnwfilterd $VIRTNWFILTERD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/qemu/virtqemud.service.in b/src/qemu/virtqemud.service.in index 315359e287..032cbcbbf0 100644 --- a/src/qemu/virtqemud.service.in +++ b/src/qemu/virtqemud.service.in @@ -20,7 +20,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTQEMUD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtqemud +EnvironmentFile=-@initconfdir@/virtqemud ExecStart=@sbindir@/virtqemud $VIRTQEMUD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in index 30588279f8..11507207a1 100644 --- a/src/remote/libvirtd.service.in +++ b/src/remote/libvirtd.service.in @@ -28,7 +28,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=LIBVIRTD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/libvirtd +EnvironmentFile=-@initconfdir@/libvirtd ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process diff --git a/src/remote/virtproxyd.service.in b/src/remote/virtproxyd.service.in index f9bb6b84a9..dd3bdf3429 100644 --- a/src/remote/virtproxyd.service.in +++ b/src/remote/virtproxyd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTPROXYD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtproxyd +EnvironmentFile=-@initconfdir@/virtproxyd ExecStart=@sbindir@/virtproxyd $VIRTPROXYD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/secret/virtsecretd.service.in b/src/secret/virtsecretd.service.in index 6d298c5334..774cfc3ecd 100644 --- a/src/secret/virtsecretd.service.in +++ b/src/secret/virtsecretd.service.in @@ -14,7 +14,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTSECRETD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtsecretd +EnvironmentFile=-@initconfdir@/virtsecretd ExecStart=@sbindir@/virtsecretd $VIRTSECRETD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/storage/virtstoraged.service.in b/src/storage/virtstoraged.service.in index eda4d86d37..e1a1ea6820 100644 --- a/src/storage/virtstoraged.service.in +++ b/src/storage/virtstoraged.service.in @@ -16,7 +16,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTSTORAGED_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtstoraged +EnvironmentFile=-@initconfdir@/virtstoraged ExecStart=@sbindir@/virtstoraged $VIRTSTORAGED_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/vbox/virtvboxd.service.in b/src/vbox/virtvboxd.service.in index 6f447276e9..e73206591a 100644 --- a/src/vbox/virtvboxd.service.in +++ b/src/vbox/virtvboxd.service.in @@ -15,7 +15,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTVBOXD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtvboxd +EnvironmentFile=-@initconfdir@/virtvboxd ExecStart=@sbindir@/virtvboxd $VIRTVBOXD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/src/vz/virtvzd.service.in b/src/vz/virtvzd.service.in index 2b1165c92b..bd98d96262 100644 --- a/src/vz/virtvzd.service.in +++ b/src/vz/virtvzd.service.in @@ -15,7 +15,7 @@ Documentation=https://libvirt.org [Service] Type=notify Environment=VIRTVZD_ARGS="--timeout 120" -EnvironmentFile=-@sysconfdir@/sysconfig/virtvzd +EnvironmentFile=-@initconfdir@/virtvzd ExecStart=@sbindir@/virtvzd $VIRTVZD_ARGS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in index 1c569c320d..c547218f2a 100644 --- a/tools/libvirt-guests.service.in +++ b/tools/libvirt-guests.service.in @@ -14,7 +14,7 @@ Documentation=man:libvirt-guests(8) Documentation=https://libvirt.org
[Service] -EnvironmentFile=-@sysconfdir@/sysconfig/libvirt-guests +EnvironmentFile=-@initconfdir@/libvirt-guests # Hack just call traditional service until we factor # out the code ExecStart=@libexecdir@/libvirt-guests.sh start diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 87f96af14d..016014215f 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -18,6 +18,7 @@
sysconfdir="@sysconfdir@" localstatedir="@localstatedir@" +initconfdir="@initconfdir@" libvirtd="@sbindir@"/libvirtd
# Source function library. @@ -39,8 +40,8 @@ START_DELAY=0 BYPASS_CACHE=0 SYNC_TIME=0
-test -f "$sysconfdir"/sysconfig/libvirt-guests && - . "$sysconfdir"/sysconfig/libvirt-guests +test -f "$initconfdir"/libvirt-guests && + . "$initconfdir"/libvirt-guests
LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests diff --git a/tools/meson.build b/tools/meson.build index fad7f202ad..f2d58cfdcb 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -241,6 +241,7 @@ tools_conf = configuration_data({ 'sbindir': sbindir, 'schemadir': pkgdatadir / 'schemas', 'sysconfdir': sysconfdir, + 'initconfdir': initconfdir, })
configure_file( diff --git a/tools/virt-pki-validate.in b/tools/virt-pki-validate.in index 7100eafb63..c91f247ba5 100644 --- a/tools/virt-pki-validate.in +++ b/tools/virt-pki-validate.in @@ -73,6 +73,7 @@ echo Found "$CERTOOL" # SYSCONFDIR="@sysconfdir@" PKI="$SYSCONFDIR/pki" +INITCONFDIR="@initconfdir@" if [ ! -d "$PKI" ] then echo the $PKI directory is missing, it is usually @@ -294,24 +295,24 @@ fi
if [ "$SERVER" = "1" ] then - if [ -r "$SYSCONFDIR"/sysconfig/libvirtd ] + if [ -r "$INITCONFDIR"/libvirtd ] then - if grep "^LIBVIRTD_ARGS.*--listen" "$SYSCONFDIR"/sysconfig/libvirtd \ + if grep "^LIBVIRTD_ARGS.*--listen" "$INITCONFDIR"/libvirtd \ >/dev/null 2>&1 then : else - echo Make sure "$SYSCONFDIR"/sysconfig/libvirtd is setup to listen to + echo Make sure "$INITCONFDIR"/libvirtd is setup to listen to echo TCP/IP connections and restart the libvirtd service fi fi - if [ -r "$SYSCONFDIR"/sysconfig/iptables ] + if [ -r "$INITCONFDIR"/iptables ] then - if grep "$PORT" "$SYSCONFDIR"/sysconfig/iptables >/dev/null 2>&1 + if grep "$PORT" "$INITCONFDIR"/iptables >/dev/null 2>&1
This won't work on Gentoo for example which has only service configuration options there, but since: a) the check is not thorough at all b) never worked there anyway c) can't not work more than before I think it's fine ;) Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
then : else - echo Make sure "$SYSCONFDIR"/sysconfig/iptables is setup to allow + echo Make sure "$INITCONFDIR"/iptables is setup to allow echo incoming TCP/IP connections on port $PORT and echo restart the iptables service fi -- 2.40.1

On Fri, May 05, 2023 at 01:34:50PM +0200, Martin Kletzander wrote:
On Tue, May 02, 2023 at 07:15:49PM +0200, Andrea Bolognani wrote:
- if [ -r "$SYSCONFDIR"/sysconfig/iptables ] + if [ -r "$INITCONFDIR"/iptables ] then - if grep "$PORT" "$SYSCONFDIR"/sysconfig/iptables >/dev/null 2>&1 + if grep "$PORT" "$INITCONFDIR"/iptables >/dev/null 2>&1
This won't work on Gentoo for example which has only service configuration options there, but since:
a) the check is not thorough at all b) never worked there anyway c) can't not work more than before
I think it's fine ;)
Yeah, the file doesn't exist at all on my Fedora machine, and the documentation for RHEL 7 (!) says something about firewalld making it obsolete. Debian doesn't seem to have it either. The code has been the same since the script was introduced in 2009, so I think it's just a consequence of the world changing around it. We could probably look into dropping that part of the script, but that's a task for someone else I think :) -- Andrea Bolognani / Red Hat / Virtualization

The default would already work fine for Fedora and RHEL, but it's better to be explicit. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- libvirt.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index dae9c87aa4..c542ec3b2b 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1213,6 +1213,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec) %meson \ -Drunstatedir=%{_rundir} \ + -Dinitconfdir=%{_sysconfdir}/sysconfig \ %{?arg_qemu} \ %{?arg_openvz} \ %{?arg_lxc} \ -- 2.40.1

On Tue, May 02, 2023 at 07:15:50PM +0200, Andrea Bolognani wrote:
The default would already work fine for Fedora and RHEL, but it's better to be explicit.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
--- libvirt.spec.in | 1 + 1 file changed, 1 insertion(+)
diff --git a/libvirt.spec.in b/libvirt.spec.in index dae9c87aa4..c542ec3b2b 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1213,6 +1213,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/libvirt.spec)
%meson \ -Drunstatedir=%{_rundir} \ + -Dinitconfdir=%{_sysconfdir}/sysconfig \ %{?arg_qemu} \ %{?arg_openvz} \ %{?arg_lxc} \ -- 2.40.1

We're about to introduce another user of the value in a different scope. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8da987b1cb..8848e58995 100644 --- a/meson.build +++ b/meson.build @@ -24,6 +24,11 @@ if git and not get_option('no_git') endif +# detect operating system + +os_release = run_command('grep', '-E', '^ID(_LIKE)*=', '/etc/os-release', check: false).stdout() + + # prepare build configuration data conf = configuration_data() @@ -1618,7 +1623,6 @@ if not get_option('driver_qemu').disabled() qemu_user = 'root' qemu_group = 'wheel' else - os_release = run_command('grep', '-E', '^ID(_LIKE)*=', '/etc/os-release', check: false).stdout() if os_release.contains('arch') qemu_user = 'nobody' qemu_group = 'nobody' -- 2.40.1

On Tue, May 02, 2023 at 07:15:51PM +0200, Andrea Bolognani wrote:
We're about to introduce another user of the value in a different scope.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

Keep /etc/sysconfig as the fallback, but pick more suitable values for various Linux distros. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8848e58995..f04703b810 100644 --- a/meson.build +++ b/meson.build @@ -83,7 +83,16 @@ endif initconfdir = get_option('initconfdir') if initconfdir == '' - initconfdir = sysconfdir / 'sysconfig' + if (os_release.contains('alpine') or + os_release.contains('arch') or + os_release.contains('gentoo')) + initconfdir = sysconfdir / 'conf.d' + # Ubuntu has ID_LIKE=debian + elif os_release.contains('debian') + initconfdir = sysconfdir / 'default' + else + initconfdir = sysconfdir / 'sysconfig' + endif endif bindir = prefix / get_option('bindir') -- 2.40.1

On Tue, May 02, 2023 at 07:15:52PM +0200, Andrea Bolognani wrote:
Keep /etc/sysconfig as the fallback, but pick more suitable values for various Linux distros.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- meson.build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build index 8848e58995..f04703b810 100644 --- a/meson.build +++ b/meson.build @@ -83,7 +83,16 @@ endif
initconfdir = get_option('initconfdir') if initconfdir == '' - initconfdir = sysconfdir / 'sysconfig' + if (os_release.contains('alpine') or + os_release.contains('arch') or + os_release.contains('gentoo'))
I can't vouch for all of these, but from my limited memory and search-engine-fu I think you're right here. There might be more and more caveats when migrated to systemd for example, especially with custom envvar files, but that's beside the point here. Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
+ initconfdir = sysconfdir / 'conf.d' + # Ubuntu has ID_LIKE=debian + elif os_release.contains('debian') + initconfdir = sysconfdir / 'default' + else + initconfdir = sysconfdir / 'sysconfig' + endif endif
bindir = prefix / get_option('bindir') -- 2.40.1

On Fri, May 05, 2023 at 01:37:59PM +0200, Martin Kletzander wrote:
On Tue, May 02, 2023 at 07:15:52PM +0200, Andrea Bolognani wrote:
initconfdir = get_option('initconfdir') if initconfdir == '' - initconfdir = sysconfdir / 'sysconfig' + if (os_release.contains('alpine') or + os_release.contains('arch') or + os_release.contains('gentoo'))
I can't vouch for all of these, but from my limited memory and search-engine-fu I think you're right here. There might be more and more caveats when migrated to systemd for example, especially with custom envvar files, but that's beside the point here.
I've just looked at what the official package in each distribution is doing: https://git.alpinelinux.org/aports/tree/community/libvirt/APKBUILD#n131 https://github.com/archlinux/svntogit-community/blob/packages/libvirt/trunk/... https://gitweb.gentoo.org/repo/gentoo.git/tree/app-emulation/libvirt/files/l... https://salsa.debian.org/libvirt-team/libvirt/-/blob/debian/latest/debian/pa... We can always tweak things later, of course. Thanks for the review! I'll push the patches now :) -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Martin Kletzander