[PATCH] spec: Restart sockets even when libvirtd is inactive

Jim Fehlig posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220719235157.15653-1-jfehlig@suse.com
libvirt.spec.in | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
[PATCH] spec: Restart sockets even when libvirtd is inactive
Posted by Jim Fehlig 1 year, 9 months ago
By default libvirtd will terminate itself after 120 seconds, so it is
likely that the daemon will not be running at package upgrade. Try
restarting sockets even if the daemon is inactive.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---

Assuming sockets need restarted on package update?

 libvirt.spec.in | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 9d788b790f..5201a14431 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1365,16 +1365,19 @@ then
         # own the sockets again when it comes back up. Thus we must
         # do this particular ordering, so that we get libvirtd
         # running with socket activation in use
+        is_active=no
         /bin/systemctl is-active libvirtd.service 1>/dev/null 2>&1
         if test $? = 0
         then
+            is_active=yes
             /bin/systemctl stop libvirtd.service >/dev/null 2>&1 || :
-
-            /bin/systemctl try-restart \
-                    libvirtd.socket \
-                    libvirtd-ro.socket \
-                    libvirtd-admin.socket >/dev/null 2>&1 || :
-
+        fi
+        /bin/systemctl try-restart \
+                libvirtd.socket \
+                libvirtd-ro.socket \
+                libvirtd-admin.socket >/dev/null 2>&1 || :
+        if test "$is_active" = yes
+        then
             /bin/systemctl start libvirtd.service >/dev/null 2>&1 || :
         fi
     fi
-- 
2.36.1
Re: [PATCH] spec: Restart sockets even when libvirtd is inactive
Posted by Martin Kletzander 1 year, 9 months ago
On Tue, Jul 19, 2022 at 05:51:57PM -0600, Jim Fehlig wrote:
>By default libvirtd will terminate itself after 120 seconds, so it is
>likely that the daemon will not be running at package upgrade. Try
>restarting sockets even if the daemon is inactive.
>
>Signed-off-by: Jim Fehlig <jfehlig@suse.com>
>---
>
>Assuming sockets need restarted on package update?
>

Probably not, but just in case there is a configuration change I think
it is safer to have this here.

> libvirt.spec.in | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
>diff --git a/libvirt.spec.in b/libvirt.spec.in
>index 9d788b790f..5201a14431 100644
>--- a/libvirt.spec.in
>+++ b/libvirt.spec.in
>@@ -1365,16 +1365,19 @@ then
>         # own the sockets again when it comes back up. Thus we must
>         # do this particular ordering, so that we get libvirtd
>         # running with socket activation in use
>+        is_active=no
>         /bin/systemctl is-active libvirtd.service 1>/dev/null 2>&1
>         if test $? = 0

I think this is not needed because this whole function is only called
when the daemon was active (see libvirt_daemon_schedule_restart and
libvirt_daemon_needs_restart).

That could make this whole thing even easier.

>         then
>+            is_active=yes
>             /bin/systemctl stop libvirtd.service >/dev/null 2>&1 || :
>-
>-            /bin/systemctl try-restart \
>-                    libvirtd.socket \
>-                    libvirtd-ro.socket \
>-                    libvirtd-admin.socket >/dev/null 2>&1 || :
>-
>+        fi
>+        /bin/systemctl try-restart \
>+                libvirtd.socket \
>+                libvirtd-ro.socket \
>+                libvirtd-admin.socket >/dev/null 2>&1 || :
>+        if test "$is_active" = yes
>+        then
>             /bin/systemctl start libvirtd.service >/dev/null 2>&1 || :
>         fi
>     fi
>-- 
>2.36.1
>