[libvirt] [PATCH 8/8] Restart daemon at end of transaction

Daniel P. Berrange berrange at redhat.com
Tue Apr 3 12:48:57 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

It is not safe to restart libvirtd after install of the
libvirt-daemon RPM, since the corresponding driver modules
may not yet have been installed by RPM. The solution is to
move the restart logic to a %posttrans script. This runs
at completion of the RPM transaction, once everything is
uninstalled.
---
 libvirt.spec.in |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index d867b09..73e1ec3 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1188,9 +1188,6 @@ fi
 %endif
 
 /sbin/chkconfig --add libvirtd
-if [ "$1" -ge "1" ]; then
-	/sbin/service libvirtd condrestart > /dev/null 2>&1
-fi
 %endif
 
 %preun daemon
@@ -1207,13 +1204,21 @@ if [ $1 = 0 ]; then
 fi
 %endif
 
-%postun daemon
 %if %{with_systemd}
+%postun daemon
 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%endif
+
+%posttrans daemon
+%if %{with_systemd}
 if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
     /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :
 fi
+%else
+if [ "$1" -ge "1" ]; then
+    /sbin/service libvirtd condrestart > /dev/null 2>&1
+fi
 %endif
 
 %if %{with_network}
-- 
1.7.7.6




More information about the libvir-list mailing list