mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
vircgroup: cleanup controllers not managed by systemd on error
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>
This commit is contained in:
parent
95d19cd015
commit
1602aa28f8
@ -1551,6 +1551,7 @@ virCgroupNewMachineSystemd(const char *name,
|
|||||||
int rv;
|
int rv;
|
||||||
virCgroupPtr init;
|
virCgroupPtr init;
|
||||||
VIR_AUTOFREE(char *) path = NULL;
|
VIR_AUTOFREE(char *) path = NULL;
|
||||||
|
virErrorPtr saved = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
|
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
|
||||||
if ((rv = virSystemdCreateMachine(name,
|
if ((rv = virSystemdCreateMachine(name,
|
||||||
@ -1584,20 +1585,24 @@ virCgroupNewMachineSystemd(const char *name,
|
|||||||
|
|
||||||
if (virCgroupEnableMissingControllers(path, pidleader,
|
if (virCgroupEnableMissingControllers(path, pidleader,
|
||||||
controllers, group) < 0) {
|
controllers, group) < 0) {
|
||||||
return -1;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virCgroupAddTask(*group, pidleader) < 0) {
|
if (virCgroupAddTask(*group, pidleader) < 0)
|
||||||
virErrorPtr saved = virSaveLastError();
|
goto error;
|
||||||
virCgroupRemove(*group);
|
|
||||||
virCgroupFree(group);
|
|
||||||
if (saved) {
|
|
||||||
virSetError(saved);
|
|
||||||
virFreeError(saved);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
saved = virSaveLastError();
|
||||||
|
virCgroupRemove(*group);
|
||||||
|
virCgroupFree(group);
|
||||||
|
if (saved) {
|
||||||
|
virSetError(saved);
|
||||||
|
virFreeError(saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user