render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
119c2d
From f38b129e38b73cb20a2d858de7b593d09380e548 Mon Sep 17 00:00:00 2001
119c2d
Message-Id: <f38b129e38b73cb20a2d858de7b593d09380e548@dist-git>
119c2d
From: Martin Kletzander <mkletzan@redhat.com>
119c2d
Date: Wed, 23 Feb 2022 10:45:28 +0100
119c2d
Subject: [PATCH] util: Fix machined servicename
119c2d
119c2d
Commit 4e42686adef8 wrongly assumed how g_variant_new_parsed() works and broke
119c2d
starting of domains on systems with systemd (machined).
119c2d
119c2d
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
119c2d
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
119c2d
(cherry picked from commit a64e666a112d4d6299d1b73704d176283bc42b19)
119c2d
119c2d
https://bugzilla.redhat.com/show_bug.cgi?id=1868537
119c2d
119c2d
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
119c2d
---
119c2d
 src/util/virsystemd.c | 12 ++++++------
119c2d
 1 file changed, 6 insertions(+), 6 deletions(-)
119c2d
119c2d
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
119c2d
index f156c2f39a..a8af80c495 100644
119c2d
--- a/src/util/virsystemd.c
119c2d
+++ b/src/util/virsystemd.c
119c2d
@@ -360,6 +360,7 @@ int virSystemdCreateMachine(const char *name,
119c2d
     g_autofree char *creatorname = NULL;
119c2d
     g_autofree char *slicename = NULL;
119c2d
     g_autofree char *scopename = NULL;
119c2d
+    g_autofree char *servicename = NULL;
119c2d
     static int hasCreateWithNetwork = 1;
119c2d
 
119c2d
     if ((rc = virSystemdHasMachined()) < 0)
119c2d
@@ -369,6 +370,7 @@ int virSystemdCreateMachine(const char *name,
119c2d
         return -1;
119c2d
 
119c2d
     creatorname = g_strdup_printf("libvirt-%s", drivername);
119c2d
+    servicename = g_strdup_printf("virt%sd.service", drivername);
119c2d
 
119c2d
     if (partition) {
119c2d
         if (!(slicename = virSystemdMakeSliceName(partition)))
119c2d
@@ -440,11 +442,10 @@ int virSystemdCreateMachine(const char *name,
119c2d
         gnicindexes = g_variant_new_fixed_array(G_VARIANT_TYPE("i"),
119c2d
                                                 nicindexes, nnicindexes, sizeof(int));
119c2d
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
119c2d
-                                      " ('After', <['libvirtd.service']>),"
119c2d
-                                      " ('After', <['virt%sd.service']>),"
119c2d
+                                      " ('After', <['libvirtd.service', %s]>),"
119c2d
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
119c2d
                                       slicename,
119c2d
-                                      drivername);
119c2d
+                                      servicename);
119c2d
         message = g_variant_new("(s@ayssus@ai@a(sv))",
119c2d
                                 name,
119c2d
                                 guuid,
119c2d
@@ -490,11 +491,10 @@ int virSystemdCreateMachine(const char *name,
119c2d
         guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
119c2d
                                           uuid, 16, sizeof(unsigned char));
119c2d
         gprops = g_variant_new_parsed("[('Slice', <%s>),"
119c2d
-                                      " ('After', <['libvirtd.service']>),"
119c2d
-                                      " ('After', <['virt%sd.service']>),"
119c2d
+                                      " ('After', <['libvirtd.service', %s]>),"
119c2d
                                       " ('Before', <['virt-guest-shutdown.target']>)]",
119c2d
                                       slicename,
119c2d
-                                      drivername);
119c2d
+                                      servicename);
119c2d
         message = g_variant_new("(s@ayssus@a(sv))",
119c2d
                                 name,
119c2d
                                 guuid,
119c2d
-- 
119c2d
2.35.1
119c2d