On 7/11/19 4:07 PM, Daniel P. Berrangé wrote:
We don't do socket activation of libvirtd, since we need to
unconditionally start libvirtd in order to perform autostart. This
doesn't mean we can't have systemd socket units. Some use cases will
not need libvirt's autostart & are thus free to use activation.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
libvirt.spec.in | 24 +++++++++++++++++++-
src/remote/Makefile.inc.am | 35 +++++++++++++++++++++++++++++
src/remote/libvirtd-admin.socket.in | 13 +++++++++++
src/remote/libvirtd-ro.socket.in | 13 +++++++++++
src/remote/libvirtd-tcp.socket.in | 12 ++++++++++
src/remote/libvirtd-tls.socket.in | 12 ++++++++++
src/remote/libvirtd.service.in | 10 ++++-----
src/remote/libvirtd.socket.in | 11 +++++++++
8 files changed, 124 insertions(+), 6 deletions(-)
create mode 100644 src/remote/libvirtd-admin.socket.in
create mode 100644 src/remote/libvirtd-ro.socket.in
create mode 100644 src/remote/libvirtd-tcp.socket.in
create mode 100644 src/remote/libvirtd-tls.socket.in
create mode 100644 src/remote/libvirtd.socket.in
diff --git a/libvirt.spec.in b/libvirt.spec.in
index d54f58f1d4..ec562d5f7a 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1342,6 +1342,8 @@ exit 0
%systemd_post virtlockd.socket virtlockd-admin.socket
%systemd_post virtlogd.socket virtlogd-admin.socket
+%systemd_post libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
+%systemd_post libvirtd-tcp.socket libvirtd-tls.socket
%systemd_post libvirtd.service
# request daemon restart in posttrans
@@ -1350,6 +1352,8 @@ touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
%preun daemon
%systemd_preun libvirtd.service
+%systemd_preun libvirtd-tcp.socket libvirtd-tls.socket
+%systemd_preun libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service
%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service
@@ -1374,7 +1378,20 @@ fi
%posttrans daemon
if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
- /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
+ /bin/systemctl is-active libvirtd.service 1>/dev/null 2>&1
+ # Old libvirtd owns the sockets and will delete them on
+ # shutdown. Can't use a try-restart as libvirtd will simply
+ # own the sockets again when it comes back up. Thus we must
+ # do this particular ordering
+ if test $? == 0 ; then
s/==/=/
+ /bin/systemctl stop libvirtd.service >/dev/null
2>&1 || :
+
+ /bin/systemctl try-restart libvirtd.socket >/dev/null 2>&1 || :
+ /bin/systemctl try-restart libvirtd-ro.socket >/dev/null 2>&1 || :
+ /bin/systemctl try-restart libvirtd-admin.socket >/dev/null 2>&1 || :
+
+ /bin/systemctl start libvirtd.service >/dev/null 2>&1 || :
+ fi
fi
rm -rf %{_localstatedir}/lib/rpm-state/libvirt || :
Michal