render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From ddea95c1c2e32c6454c89aa83d78b26a83564cd4 Mon Sep 17 00:00:00 2001
Message-Id: <ddea95c1c2e32c6454c89aa83d78b26a83564cd4@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:11 +0200
Subject: [PATCH] Revert "vircgroup: cleanup controllers not managed by systemd
 on error"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry picked from commit 199eee6aae7af3d813fbe98660c7e0fa1a8ae7b7)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <53288dd310e0305ac3179693e64684eb8b3a31ab.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroup.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a376b9b89a..7ec1399bc6 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1059,7 +1059,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,
@@ -1092,24 +1091,20 @@ virCgroupNewMachineSystemd(const char *name,
 
     if (virCgroupEnableMissingControllers(path, pidleader,
                                           controllers, group) < 0) {
-        goto error;
+        return -1;
     }
 
-    if (virCgroupAddProcess(*group, pidleader) < 0)
-        goto error;
+    if (virCgroupAddProcess(*group, pidleader) < 0) {
+        virErrorPtr saved = virSaveLastError();
+        virCgroupRemove(*group);
+        virCgroupFree(group);
+        if (saved) {
+            virSetError(saved);
+            virFreeError(saved);
+        }
+    }
 
     return 0;
-
- error:
-    saved = virSaveLastError();
-    virCgroupRemove(*group);
-    virCgroupFree(group);
-    if (saved) {
-        virSetError(saved);
-        virFreeError(saved);
-    }
-
-    return -1;
 }
 
 
-- 
2.22.0