]> xenbits.xensource.com Git - libvirt.git/commitdiff
Revert "vircgroup: cleanup controllers not managed by systemd on error"
authorPavel Hrdina <phrdina@redhat.com>
Thu, 27 Sep 2018 14:11:19 +0000 (16:11 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 28 Sep 2018 17:51:01 +0000 (19:51 +0200)
This reverts commit 1602aa28f820ada66f707cef3e536e8572fbda1e.

There is no need to call virCgroupRemove() nor virCgroupFree() if
virCgroupEnableMissingControllers() fails because it will not modify
'group' at all.

The cleanup of directories is done in virCgroupMakeGroup().

Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/util/vircgroup.c

index f90906e4add140bef5adf5c3a7c2370974fa4e6d..548c873da8ac8e14a5bfa18b86b62ba7d457accc 100644 (file)
@@ -1055,7 +1055,6 @@ virCgroupNewMachineSystemd(const char *name,
     int rv;
     virCgroupPtr init;
     VIR_AUTOFREE(char *) path = NULL;
-    virErrorPtr saved = NULL;
 
     VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
     if ((rv = virSystemdCreateMachine(name,
@@ -1088,24 +1087,20 @@ virCgroupNewMachineSystemd(const char *name,
 
     if (virCgroupEnableMissingControllers(path, pidleader,
                                           controllers, group) < 0) {
-        goto error;
+        return -1;
     }
 
-    if (virCgroupAddProcess(*group, pidleader) < 0)
-        goto error;
-
-    return 0;
-
- error:
-    saved = virSaveLastError();
-    virCgroupRemove(*group);
-    virCgroupFree(group);
-    if (saved) {
-        virSetError(saved);
-        virFreeError(saved);
+    if (virCgroupAddProcess(*group, pidleader) < 0) {
+        virErrorPtr saved = virSaveLastError();
+        virCgroupRemove(*group);
+        virCgroupFree(group);
+        if (saved) {
+            virSetError(saved);
+            virFreeError(saved);
+        }
     }
 
-    return -1;
+    return 0;
 }