libvirt/SOURCES/libvirt-vircgroup-cleanup-c...

78 lines
2.3 KiB
Diff

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