render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c313de
From 9831bda48172881b14f3c473b625ce5ddbd04300 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <9831bda48172881b14f3c473b625ce5ddbd04300@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:06:08 +0200
c313de
Subject: [PATCH] vircgroup: Call virCgroupRemove inside virCgroupMakeGroup
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
This fixes virCgroupEnableMissingControllers where virCgroupRemove
c313de
was not called in case virCgroupMakeGroup failed.
c313de
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit b013bdfd797489e6c254917da299842fe051d058)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <09accbd84f3da1d7c6682357cf6c9a720631a247.1561993099.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/util/vircgroup.c | 18 +++++++++---------
c313de
 1 file changed, 9 insertions(+), 9 deletions(-)
c313de
c313de
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c313de
index 8646a4a479..dde9ed21a2 100644
c313de
--- a/src/util/vircgroup.c
c313de
+++ b/src/util/vircgroup.c
c313de
@@ -1052,7 +1052,7 @@ virCgroupMakeGroup(virCgroupPtr parent,
c313de
         }
c313de
 
c313de
         if (virCgroupPathOfController(group, i, "", &path) < 0)
c313de
-            return -1;
c313de
+            goto error;
c313de
 
c313de
         /* As of Feb 2011, clang can't see that the above function
c313de
          * call did not modify group. */
c313de
@@ -1076,7 +1076,7 @@ virCgroupMakeGroup(virCgroupPtr parent,
c313de
                     virReportSystemError(errno,
c313de
                                          _("Failed to create controller %s for group"),
c313de
                                          virCgroupControllerTypeToString(i));
c313de
-                    return -1;
c313de
+                    goto error;
c313de
                 }
c313de
             }
c313de
             if (group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoint != NULL &&
c313de
@@ -1084,7 +1084,7 @@ virCgroupMakeGroup(virCgroupPtr parent,
c313de
                  STREQ(group->controllers[i].mountPoint,
c313de
                        group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoint))) {
c313de
                 if (virCgroupCpuSetInherit(parent, group) < 0)
c313de
-                    return -1;
c313de
+                    goto error;
c313de
             }
c313de
             /*
c313de
              * Note that virCgroupSetMemoryUseHierarchy should always be
c313de
@@ -1096,13 +1096,17 @@ virCgroupMakeGroup(virCgroupPtr parent,
c313de
                  STREQ(group->controllers[i].mountPoint,
c313de
                        group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoint))) {
c313de
                 if (virCgroupSetMemoryUseHierarchy(group) < 0)
c313de
-                    return -1;
c313de
+                    goto error;
c313de
             }
c313de
         }
c313de
     }
c313de
 
c313de
     VIR_DEBUG("Done making controllers for group");
c313de
     return 0;
c313de
+
c313de
+ error:
c313de
+    virCgroupRemove(group);
c313de
+    return -1;
c313de
 }
c313de
 
c313de
 
c313de
@@ -1316,10 +1320,8 @@ virCgroupNewPartition(const char *path,
c313de
         if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0)
c313de
             goto cleanup;
c313de
 
c313de
-        if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0) {
c313de
-            virCgroupRemove(*group);
c313de
+        if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0)
c313de
             goto cleanup;
c313de
-        }
c313de
     }
c313de
 
c313de
     ret = 0;
c313de
@@ -1389,7 +1391,6 @@ virCgroupNewDomainPartition(virCgroupPtr partition,
c313de
      */
c313de
     if (virCgroupMakeGroup(partition, *group, create,
c313de
                            VIR_CGROUP_MEM_HIERACHY) < 0) {
c313de
-        virCgroupRemove(*group);
c313de
         virCgroupFree(group);
c313de
         return -1;
c313de
     }
c313de
@@ -1446,7 +1447,6 @@ virCgroupNewThread(virCgroupPtr domain,
c313de
         return -1;
c313de
 
c313de
     if (virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE) < 0) {
c313de
-        virCgroupRemove(*group);
c313de
         virCgroupFree(group);
c313de
         return -1;
c313de
     }
c313de
-- 
c313de
2.22.0
c313de