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

Eric Blake eblake at redhat.com
Wed Apr 4 04:06:05 UTC 2012


On 04/03/2012 06:48 AM, Daniel P. Berrange wrote:
> 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(-)

I haven't used %posttrans before, but it looks simple enough.  What I'm
not sure of...

> 
> 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

is why daemon-reload can be done right away,

> +
> +%posttrans daemon
> +%if %{with_systemd}
>  if [ $1 -ge 1 ] ; then
>      # Package upgrade, not uninstall
>      /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 || :

but a full restart has to wait for %posttrans.  I was naively assuming
they should both be %posttrans.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120403/393271d1/attachment-0001.sig>


More information about the libvir-list mailing list