From dc6b512f3c0711c9841b09aaea4ef006ef2be6b1 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrangé Date: Aug 04 2021 17:01:17 +0000 Subject: switch to use modular daemons by default Signed-off-by: Daniel P. Berrangé --- diff --git a/libvirt.spec b/libvirt.spec index bf5b7c4..e0dc9b0 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -181,6 +181,11 @@ %define with_dmidecode 0%{!?_without_dmidecode:1} %endif +%define with_modular_daemons 0 +%if 0%{?fedora} >= 35 || 0%{?rhel} >= 9 + %define with_modular_daemons 1 +%endif + # Force QEMU to run as non-root %define qemu_user qemu %define qemu_group qemu @@ -201,7 +206,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 7.6.0 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ URL: https://libvirt.org/ @@ -1076,6 +1081,12 @@ exit 1 %define arg_libssh2 -Dlibssh2=disabled %endif +%if %{with_modular_daemons} + %define arg_remote_mode -Dremote_default_mode=direct +%else + %define arg_remote_mode -Dremote_default_mode=legacy +%endif + %define when %(date +"%%F-%%T") %define where %(hostname) %define who %{?packager}%{!?packager:Unknown} @@ -1106,7 +1117,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec) -Ddriver_vz=disabled \ -Ddriver_bhyve=disabled \ -Ddriver_ch=disabled \ - -Dremote_default_mode=legacy \ + %{?arg_remote_mode} \ -Ddriver_interface=enabled \ -Ddriver_network=enabled \ -Dstorage_fs=enabled \ @@ -1248,6 +1259,29 @@ mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \ # raising the test timeout VIR_TEST_DEBUG=1 %meson_test --no-suite syntax-check --timeout-multiplier 10 +%global libvirt_daemon_schedule_restart() mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : \ +/bin/systemctl is-active %1.service 1>/dev/null 2>&1 && \ + touch %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 || : + +%global libvirt_daemon_finish_restart() rm -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 \ +rmdir %{_localstatedir}/lib/rpm-state/libvirt 2>/dev/null || : + +%global libvirt_daemon_needs_restart() -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 + +%global libvirt_daemon_perform_restart() if test %libvirt_daemon_needs_restart %1 \ +then \ + /bin/systemctl try-restart %1.service >/dev/null 2>&1 || : \ +fi \ +%libvirt_daemon_finish_restart %1 + +%global libvirt_daemon_systemd_post() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1.service + +%global libvirt_daemon_systemd_post_inet() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.service + +%global libvirt_daemon_systemd_preun() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1.socket + +%global libvirt_daemon_systemd_preun_inet() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.socket + %pre daemon # 'libvirt' group is just to allow password-less polkit access to # libvirtd. The uid number is irrelevant, so we use dynamic allocation @@ -1257,30 +1291,25 @@ getent group libvirt >/dev/null || groupadd -r libvirt exit 0 %post daemon -%global post_units \\\ - virtlockd.socket virtlockd-admin.socket \\\ - virtlogd.socket virtlogd-admin.socket \\\ - libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\ - libvirtd-tcp.socket libvirtd-tls.socket \\\ - libvirtd.service \\\ - libvirt-guests.service +%libvirt_daemon_systemd_post virtlogd +%libvirt_daemon_systemd_post virtlockdd +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post_inet virtproxyd +%else +%libvirt_daemon_systemd_post_inet libvirtd +%endif -%systemd_post %post_units +%systemd_post libvirt-guests.service -# request daemon restart in posttrans -mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : -touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : +%libvirt_daemon_schedule_restart libvirtd %preun daemon -%global preun_units \\\ - libvirtd.service \\\ - libvirtd-tcp.socket libvirtd-tls.socket \\\ - libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\ - virtlogd.socket virtlogd-admin.socket virtlogd.service \\\ - virtlockd.socket virtlockd-admin.socket virtlockd.service \\\ - libvirt-guests.service +%systemd_preun libvirt-guests.service -%systemd_preun %preun_units +%libvirt_daemon_systemd_preun_inet libvirtd +%libvirt_daemon_systemd_preun_inet virtproxyd +%libvirt_daemon_systemd_preun virtlogd +%libvirt_daemon_systemd_preun virtlockdd %postun daemon /bin/systemctl daemon-reload >/dev/null 2>&1 || : @@ -1302,7 +1331,8 @@ if [ $1 -ge 1 ] ; then fi %posttrans daemon -if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then +if test %libvirt_daemon_needs_restart libvirtd +then # See if user has previously modified their install to # tell libvirtd to use --listen grep -E '^LIBVIRTD_ARGS=.*--listen' /etc/sysconfig/libvirtd 1>/dev/null 2>&1 @@ -1338,18 +1368,148 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then fi fi fi -rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : + +%libvirt_daemon_finish_restart libvirtd %post daemon-driver-network %if %{with_firewalld_zone} %firewalld_reload %endif +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtnetworkd +%endif +%libvirt_daemon_schedule_restart virtnetworkd + +%preun +%libvirt_daemon_systemd_preun virtnetworkd + %postun daemon-driver-network %if %{with_firewalld_zone} %firewalld_reload %endif +%posttrans daemon-driver-network +%libvirt_daemon_perform_restart virtnetworkd + + +%post daemon-driver-nwfilter +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtnwfilterd +%endif +%libvirt_daemon_schedule_restart virtnwfilterd + +%preun daemon-driver-nwfilter +%libvirt_daemon_systemd_preun virtnwfilterd + +%posttrans daemon-driver-nwfilter +%libvirt_daemon_perform_restart virtnwfilterd + + +%post daemon-driver-nodedev +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtnodedevd +%endif +%libvirt_daemon_schedule_restart virtnodedevd + +%preun daemon-driver-nodedev +%libvirt_daemon_systemd_preun virtnodedevd + +%posttrans daemon-driver-nodedev +%libvirt_daemon_perform_restart virtnodedevd + + +%post daemon-driver-interface +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtinterfaced +%endif +%libvirt_daemon_schedule_restart virtinterfaced + +%preun daemon-driver-interface +%libvirt_daemon_systemd_preun virtinterfaced + +%posttrans daemon-driver-interface +%libvirt_daemon_perform_restart virtinterfaced + + +%post daemon-driver-secret +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtsecretd +%endif +%libvirt_daemon_schedule_restart virtsecretd + +%preun daemon-driver-secret +%libvirt_daemon_systemd_preun virtsecretd + +%posttranstrans daemon-driver-secret +%libvirt_daemon_perform_restart virtsecretd + + +%post daemon-driver-storage +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtstoraged +%endif +%libvirt_daemon_schedule_restart virtstoraged + +%preun daemon-driver-storage +%libvirt_daemon_systemd_preun virtstoraged + +%posttrans daemon-driver-storage +%libvirt_daemon_perform_restart virtstoraged + + +%post daemon-driver-qemu +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtqemud +%endif +%libvirt_daemon_schedule_restart virtqemud + +%preun daemon-driver-qemu +%libvirt_daemon_systemd_preun virtqemud + +%posttrans daemon-driver-qemu +%libvirt_daemon_perform_restart virtqemud + + +%post daemon-driver-lxc +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtlxcd +%endif +%libvirt_daemon_schedule_restart virtlxcd + +%preun daemon-driver-lxc +%libvirt_daemon_systemd_preun virtlxcd + +%posttrans daemon-driver-lxc +%libvirt_daemon_perform_restart virtlxcd + + +%post daemon-driver-vbox +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtvboxd +%endif +%libvirt_daemon_schedule_restart virtvboxd + +%preun daemon-driver-vbox +%libvirt_daemon_systemd_preun virtvboxd + +%posttrans daemon-driver-vbox +%libvirt_daemon_perform_restart virtvboxd + + +%post daemon-driver-libxl +%if %{with_modular_daemons} +%libvirt_daemon_systemd_post virtxend +%endif +%libvirt_daemon_schedule_restart virtxend + +%preun daemon-driver-libxl +%libvirt_daemon_systemd_preun virtxend + +%posttrans daemon-driver-libxl +%libvirt_daemon_perform_restart virtxend + + %post daemon-config-network if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; then # see if the network used by default network creates a conflict, @@ -1388,15 +1548,13 @@ if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; chmod 0600 %{_sysconfdir}/libvirt/qemu/networks/default.xml # Make sure libvirt picks up the new network defininiton - mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : - touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : + %libvirt_daemon_schedule_restart libvirtd + %libvirt_daemon_schedule_restart virtnetworkd fi %posttrans daemon-config-network -if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then - /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : -fi -rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : +%libvirt_daemon_perform_restart libvirtd +%libvirt_daemon_perform_restart virtnetworkd %post daemon-config-nwfilter for datadir_file in %{_datadir}/libvirt/nwfilter/*.xml; do @@ -1407,15 +1565,12 @@ for datadir_file in %{_datadir}/libvirt/nwfilter/*.xml; do fi done # Make sure libvirt picks up the new nwfilter defininitons -mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : -touch %{_localstatedir}/lib/rpm-state/libvirt/restart || : +%libvirt_daemon_schedule_restart libvirtd +%libvirt_daemon_schedule_restart virtnwfilterd %posttrans daemon-config-nwfilter -if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then - /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || : -fi -rm -rf %{_localstatedir}/lib/rpm-state/libvirt || : - +%libvirt_daemon_perform_restart libvirtd +%libvirt_daemon_perform_restart virtnwfilterd %if %{with_qemu} %pre daemon-driver-qemu @@ -1902,6 +2057,9 @@ exit 0 %changelog +* Wed Aug 4 2021 Daniel P. Berrangé - 7.6.0-2 +- Switch to use modular daemons by default + * Mon Aug 2 2021 Daniel P. Berrangé - 7.6.0-1 - Update to 7.6.0 release