render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
119c2d
From ee1ce580f5373070e4b6a50d1ae4a3218c737a72 Mon Sep 17 00:00:00 2001
119c2d
Message-Id: <ee1ce580f5373070e4b6a50d1ae4a3218c737a72@dist-git>
119c2d
From: Martin Kletzander <mkletzan@redhat.com>
119c2d
Date: Mon, 14 Feb 2022 12:37:37 +0100
119c2d
Subject: [PATCH] Make systemd unit ordering more robust
119c2d
119c2d
Since libvirt-guests script/service can operate on various URIs and we do
119c2d
support both socket activation and traditional services, the ordering should be
119c2d
specified for all the possible sockets and services.
119c2d
119c2d
Also remove the Wants= dependency since do not want to start any service.  We
119c2d
cannot know which one libvirt-guests is configured, so we'd have to start all
119c2d
the daemons which would break if unused colliding services are not
119c2d
masked (libvirtd.service in the modular case and all the modular daemon service
119c2d
units in the monolithic scenario).  Fortunately we can assume that the system is
119c2d
configured properly to start services/sockets that are of interest to the user.
119c2d
That also works with the setup described in https://libvirt.org/daemons.html .
119c2d
119c2d
To make it even more robust we add the daemon service into the machine units
119c2d
created for individual domains as it was missing there.
119c2d
119c2d
https://bugzilla.redhat.com/show_bug.cgi?id=1868537
119c2d
119c2d
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
119c2d
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
119c2d
(cherry picked from commit 4e42686adef8b9e9266f0099ddcd25bc95c4ed43)
119c2d
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
119c2d
---
119c2d
 src/util/virsystemd.c           |  8 ++++++--
119c2d
 tools/libvirt-guests.service.in | 12 +++++++++++-
119c2d
 2 files changed, 17 insertions(+), 3 deletions(-)
119c2d
119c2d
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
119c2d
index a86d4c6bb9..f156c2f39a 100644
119c2d
--- a/src/util/virsystemd.c
119c2d
+++ b/src/util/virsystemd.c
119c2d
@@ -441,8 +441,10 @@ int virSystemdCreateMachine(const char *name,
119c2d
                                                 nicindexes, nnicindexes, sizeof(int));
119c2d
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
119c2d
                                       " ('After', <['libvirtd.service']>),"
119c2d
+                                      " ('After', <['virt%sd.service']>),"
119c2d
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
119c2d
-                                      slicename);
119c2d
+                                      slicename,
119c2d
+                                      drivername);
119c2d
         message = g_variant_new("(s@ayssus@ai@a(sv))",
119c2d
                                 name,
119c2d
                                 guuid,
119c2d
@@ -489,8 +491,10 @@ int virSystemdCreateMachine(const char *name,
119c2d
                                           uuid, 16, sizeof(unsigned char));
119c2d
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
119c2d
                                       " ('After', <['libvirtd.service']>),"
119c2d
+                                      " ('After', <['virt%sd.service']>),"
119c2d
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
119c2d
-                                      slicename);
119c2d
+                                      slicename,
119c2d
+                                      drivername);
119c2d
         message = g_variant_new("(s@ayssus@a(sv))",
119c2d
                                 name,
119c2d
                                 guuid,
119c2d
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
119c2d
index 1a9b233e11..3cf6476196 100644
119c2d
--- a/tools/libvirt-guests.service.in
119c2d
+++ b/tools/libvirt-guests.service.in
119c2d
@@ -1,10 +1,20 @@
119c2d
 [Unit]
119c2d
 Description=Suspend/Resume Running libvirt Guests
119c2d
-Wants=libvirtd.service
119c2d
 Requires=virt-guest-shutdown.target
119c2d
 After=network.target
119c2d
 After=time-sync.target
119c2d
+After=libvirtd.socket
119c2d
+After=virtqemud.socket
119c2d
+After=virtlxcd.socket
119c2d
+After=virtvboxd.socket
119c2d
+After=virtvzd.socket
119c2d
+After=virtxend.socket
119c2d
 After=libvirtd.service
119c2d
+After=virtqemud.service
119c2d
+After=virtlxcd.service
119c2d
+After=virtvboxd.service
119c2d
+After=virtvzd.service
119c2d
+After=virtxend.service
119c2d
 After=virt-guest-shutdown.target
119c2d
 Documentation=man:libvirt-guests(8)
119c2d
 Documentation=https://libvirt.org
119c2d
-- 
119c2d
2.35.1
119c2d