Blame SOURCES/libvirt-vircgroup-cleanup-controllers-not-managed-by-systemd-on-error.patch

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