render / rpms / libvirt

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