Pablo Greco 40546a
From b77a6e6821bc45e4761fc7b23665f585761570ca Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <b77a6e6821bc45e4761fc7b23665f585761570ca@dist-git>
Pablo Greco 40546a
From: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
Date: Mon, 1 Jul 2019 17:06:12 +0200
Pablo Greco 40546a
Subject: [PATCH] vircgroup: cleanup controllers not managed by systemd on
Pablo Greco 40546a
 error
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
If virCgroupEnableMissingControllers() fails it could have already
Pablo Greco 40546a
created some directories, we should clean it up as well.
Pablo Greco 40546a
Pablo Greco 40546a
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
(cherry picked from commit 1602aa28f820ada66f707cef3e536e8572fbda1e)
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: <e056c233653eaf09f55643fc075e17506bb754e2.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 | 25 +++++++++++++++----------
Pablo Greco 40546a
 1 file changed, 15 insertions(+), 10 deletions(-)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
Pablo Greco 40546a
index 64507bf8aa..6aa30a82be 100644
Pablo Greco 40546a
--- a/src/util/vircgroup.c
Pablo Greco 40546a
+++ b/src/util/vircgroup.c
Pablo Greco 40546a
@@ -1555,6 +1555,7 @@ virCgroupNewMachineSystemd(const char *name,
Pablo Greco 40546a
     int rv;
Pablo Greco 40546a
     virCgroupPtr init;
Pablo Greco 40546a
     VIR_AUTOFREE(char *) path = NULL;
Pablo Greco 40546a
+    virErrorPtr saved = NULL;
Pablo Greco 40546a
 
Pablo Greco 40546a
     VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
Pablo Greco 40546a
     if ((rv = virSystemdCreateMachine(name,
Pablo Greco 40546a
@@ -1588,20 +1589,24 @@ virCgroupNewMachineSystemd(const char *name,
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (virCgroupEnableMissingControllers(path, pidleader,
Pablo Greco 40546a
                                           controllers, group) < 0) {
Pablo Greco 40546a
-        return -1;
Pablo Greco 40546a
+        goto error;
Pablo Greco 40546a
     }
Pablo Greco 40546a
 
Pablo Greco 40546a
-    if (virCgroupAddTask(*group, pidleader) < 0) {
Pablo Greco 40546a
-        virErrorPtr saved = virSaveLastError();
Pablo Greco 40546a
-        virCgroupRemove(*group);
Pablo Greco 40546a
-        virCgroupFree(group);
Pablo Greco 40546a
-        if (saved) {
Pablo Greco 40546a
-            virSetError(saved);
Pablo Greco 40546a
-            virFreeError(saved);
Pablo Greco 40546a
-        }
Pablo Greco 40546a
-    }
Pablo Greco 40546a
+    if (virCgroupAddTask(*group, pidleader) < 0)
Pablo Greco 40546a
+        goto error;
Pablo Greco 40546a
 
Pablo Greco 40546a
     return 0;
Pablo Greco 40546a
+
Pablo Greco 40546a
+ error:
Pablo Greco 40546a
+    saved = virSaveLastError();
Pablo Greco 40546a
+    virCgroupRemove(*group);
Pablo Greco 40546a
+    virCgroupFree(group);
Pablo Greco 40546a
+    if (saved) {
Pablo Greco 40546a
+        virSetError(saved);
Pablo Greco 40546a
+        virFreeError(saved);
Pablo Greco 40546a
+    }
Pablo Greco 40546a
+
Pablo Greco 40546a
+    return -1;
Pablo Greco 40546a
 }
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a