[PATCH v3 09/16] Cleanup if creating cgroup directories fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Currently if virCgroupMakeGroup fails, we can get in a situation
where some controllers have been setup, but others not. Ensure
we call virCgroupRemove to remove what we've done upon failure

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/util/vircgroup.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index d3c43a2..bcc61a8 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1081,8 +1081,10 @@ int virCgroupNewDriver(const char *name,
     rc = virCgroupNew(name, rootgrp, -1, group);
     if (rc == 0) {
         rc = virCgroupMakeGroup(rootgrp, *group, create, VIR_CGROUP_NONE);
-        if (rc != 0)
+        if (rc != 0) {
+            virCgroupRemove(*group);
             virCgroupFree(group);
+        }
     }
 out:
     virCgroupFree(&rootgrp);
@@ -1154,8 +1156,10 @@ int virCgroupNewDomain(virCgroupPtr driver,
          * cumulative usage that we don't need.
          */
         rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_MEM_HIERACHY);
-        if (rc != 0)
+        if (rc != 0) {
+            virCgroupRemove(*group);
             virCgroupFree(group);
+        }
     }
 
     return rc;
@@ -1201,8 +1205,10 @@ int virCgroupNewVcpu(virCgroupPtr domain,
 
     if (rc == 0) {
         rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
-        if (rc != 0)
+        if (rc != 0) {
+            virCgroupRemove(*group);
             virCgroupFree(group);
+        }
     }
 
     return rc;
@@ -1241,8 +1247,10 @@ int virCgroupNewEmulator(virCgroupPtr domain,
 
     if (rc == 0) {
         rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
-        if (rc != 0)
+        if (rc != 0) {
+            virCgroupRemove(*group);
             virCgroupFree(group);
+        }
     }
 
     return rc;
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]