render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From f38b129e38b73cb20a2d858de7b593d09380e548 Mon Sep 17 00:00:00 2001
Message-Id: <f38b129e38b73cb20a2d858de7b593d09380e548@dist-git>
From: Martin Kletzander <mkletzan@redhat.com>
Date: Wed, 23 Feb 2022 10:45:28 +0100
Subject: [PATCH] util: Fix machined servicename

Commit 4e42686adef8 wrongly assumed how g_variant_new_parsed() works and broke
starting of domains on systems with systemd (machined).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit a64e666a112d4d6299d1b73704d176283bc42b19)

https://bugzilla.redhat.com/show_bug.cgi?id=1868537

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/util/virsystemd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index f156c2f39a..a8af80c495 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -360,6 +360,7 @@ int virSystemdCreateMachine(const char *name,
     g_autofree char *creatorname = NULL;
     g_autofree char *slicename = NULL;
     g_autofree char *scopename = NULL;
+    g_autofree char *servicename = NULL;
     static int hasCreateWithNetwork = 1;
 
     if ((rc = virSystemdHasMachined()) < 0)
@@ -369,6 +370,7 @@ int virSystemdCreateMachine(const char *name,
         return -1;
 
     creatorname = g_strdup_printf("libvirt-%s", drivername);
+    servicename = g_strdup_printf("virt%sd.service", drivername);
 
     if (partition) {
         if (!(slicename = virSystemdMakeSliceName(partition)))
@@ -440,11 +442,10 @@ int virSystemdCreateMachine(const char *name,
         gnicindexes = g_variant_new_fixed_array(G_VARIANT_TYPE("i"),
                                                 nicindexes, nnicindexes, sizeof(int));
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
-                                      " ('After', <['libvirtd.service']>),"
-                                      " ('After', <['virt%sd.service']>),"
+                                      " ('After', <['libvirtd.service', %s]>),"
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
                                       slicename,
-                                      drivername);
+                                      servicename);
         message = g_variant_new("(s@ayssus@ai@a(sv))",
                                 name,
                                 guuid,
@@ -490,11 +491,10 @@ int virSystemdCreateMachine(const char *name,
         guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
                                           uuid, 16, sizeof(unsigned char));
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
-                                      " ('After', <['libvirtd.service']>),"
-                                      " ('After', <['virt%sd.service']>),"
+                                      " ('After', <['libvirtd.service', %s]>),"
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
                                       slicename,
-                                      drivername);
+                                      servicename);
         message = g_variant_new("(s@ayssus@a(sv))",
                                 name,
                                 guuid,
-- 
2.35.1