Blob Blame History Raw
From 440629a5a95d167af717a70c8d992e104866229a Mon Sep 17 00:00:00 2001
Message-Id: <440629a5a95d167af717a70c8d992e104866229a@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:05:59 +0200
Subject: [PATCH] vircgroup: machinename will never be NULL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit <eaf2c9f89107b9f60cf8db2c919f78b987ff7177> moved machineName
generation before virCgroupNewDetectMachine() is called.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit f9d18f89f7df937b922816aeae0024d8bd6dc72e)

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <2e0f6a4d02b3f97f5b9efa74a6553d5ce11d077a.1561993099.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroup.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a2c971fbf4..5adf9d3c11 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -266,27 +266,22 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
     if (virCgroupPartitionEscape(&partname) < 0)
         return false;
 
-    if (machinename &&
-        (virAsprintf(&partmachinename, "%s.libvirt-%s",
-                     machinename, drivername) < 0 ||
-         virCgroupPartitionEscape(&partmachinename) < 0))
+    if (virAsprintf(&partmachinename, "%s.libvirt-%s",
+                    machinename, drivername) < 0 ||
+        virCgroupPartitionEscape(&partmachinename) < 0)
         return false;
 
     if (!(scopename_old = virSystemdMakeScopeName(name, drivername, true)))
         return false;
 
-    /* We should keep trying even if this failed */
-    if (!machinename)
-        virResetLastError();
-    else if (!(scopename_new = virSystemdMakeScopeName(machinename,
-                                                       drivername, false)))
+    if (!(scopename_new = virSystemdMakeScopeName(machinename,
+                                                  drivername, false)))
         return false;
 
     if (virCgroupPartitionEscape(&scopename_old) < 0)
         return false;
 
-    if (scopename_new &&
-        virCgroupPartitionEscape(&scopename_new) < 0)
+    if (virCgroupPartitionEscape(&scopename_new) < 0)
         return false;
 
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
@@ -315,16 +310,16 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
         tmp++;
 
         if (STRNEQ(tmp, name) &&
-            STRNEQ_NULLABLE(tmp, machinename) &&
+            STRNEQ(tmp, machinename) &&
             STRNEQ(tmp, partname) &&
-            STRNEQ_NULLABLE(tmp, partmachinename) &&
+            STRNEQ(tmp, partmachinename) &&
             STRNEQ(tmp, scopename_old) &&
-            STRNEQ_NULLABLE(tmp, scopename_new)) {
+            STRNEQ(tmp, scopename_new)) {
             VIR_DEBUG("Name '%s' for controller '%s' does not match "
                       "'%s', '%s', '%s', '%s' or '%s'",
                       tmp, virCgroupControllerTypeToString(i),
-                      name, NULLSTR(machinename), partname,
-                      scopename_old, NULLSTR(scopename_new));
+                      name, machinename, partname,
+                      scopename_old, scopename_new);
             return false;
         }
     }
-- 
2.22.0