render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 440629a5a95d167af717a70c8d992e104866229a Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <440629a5a95d167af717a70c8d992e104866229a@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:05:59 +0200
c480ed
Subject: [PATCH] vircgroup: machinename will never be NULL
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Commit <eaf2c9f89107b9f60cf8db2c919f78b987ff7177> moved machineName
c480ed
generation before virCgroupNewDetectMachine() is called.
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit f9d18f89f7df937b922816aeae0024d8bd6dc72e)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <2e0f6a4d02b3f97f5b9efa74a6553d5ce11d077a.1561993099.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroup.c | 27 +++++++++++----------------
c480ed
 1 file changed, 11 insertions(+), 16 deletions(-)
c480ed
c480ed
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c480ed
index a2c971fbf4..5adf9d3c11 100644
c480ed
--- a/src/util/vircgroup.c
c480ed
+++ b/src/util/vircgroup.c
c480ed
@@ -266,27 +266,22 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
c480ed
     if (virCgroupPartitionEscape(&partname) < 0)
c480ed
         return false;
c480ed
 
c480ed
-    if (machinename &&
c480ed
-        (virAsprintf(&partmachinename, "%s.libvirt-%s",
c480ed
-                     machinename, drivername) < 0 ||
c480ed
-         virCgroupPartitionEscape(&partmachinename) < 0))
c480ed
+    if (virAsprintf(&partmachinename, "%s.libvirt-%s",
c480ed
+                    machinename, drivername) < 0 ||
c480ed
+        virCgroupPartitionEscape(&partmachinename) < 0)
c480ed
         return false;
c480ed
 
c480ed
     if (!(scopename_old = virSystemdMakeScopeName(name, drivername, true)))
c480ed
         return false;
c480ed
 
c480ed
-    /* We should keep trying even if this failed */
c480ed
-    if (!machinename)
c480ed
-        virResetLastError();
c480ed
-    else if (!(scopename_new = virSystemdMakeScopeName(machinename,
c480ed
-                                                       drivername, false)))
c480ed
+    if (!(scopename_new = virSystemdMakeScopeName(machinename,
c480ed
+                                                  drivername, false)))
c480ed
         return false;
c480ed
 
c480ed
     if (virCgroupPartitionEscape(&scopename_old) < 0)
c480ed
         return false;
c480ed
 
c480ed
-    if (scopename_new &&
c480ed
-        virCgroupPartitionEscape(&scopename_new) < 0)
c480ed
+    if (virCgroupPartitionEscape(&scopename_new) < 0)
c480ed
         return false;
c480ed
 
c480ed
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c480ed
@@ -315,16 +310,16 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
c480ed
         tmp++;
c480ed
 
c480ed
         if (STRNEQ(tmp, name) &&
c480ed
-            STRNEQ_NULLABLE(tmp, machinename) &&
c480ed
+            STRNEQ(tmp, machinename) &&
c480ed
             STRNEQ(tmp, partname) &&
c480ed
-            STRNEQ_NULLABLE(tmp, partmachinename) &&
c480ed
+            STRNEQ(tmp, partmachinename) &&
c480ed
             STRNEQ(tmp, scopename_old) &&
c480ed
-            STRNEQ_NULLABLE(tmp, scopename_new)) {
c480ed
+            STRNEQ(tmp, scopename_new)) {
c480ed
             VIR_DEBUG("Name '%s' for controller '%s' does not match "
c480ed
                       "'%s', '%s', '%s', '%s' or '%s'",
c480ed
                       tmp, virCgroupControllerTypeToString(i),
c480ed
-                      name, NULLSTR(machinename), partname,
c480ed
-                      scopename_old, NULLSTR(scopename_new));
c480ed
+                      name, machinename, partname,
c480ed
+                      scopename_old, scopename_new);
c480ed
             return false;
c480ed
         }
c480ed
     }
c480ed
-- 
c480ed
2.22.0
c480ed