render / rpms / libvirt

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