mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
Cleanup if creating cgroup directories fails
Currently if virCgroupMakeGroup fails, we can get in a situation where some controllers have been setup, but others not. Ensure we call virCgroupRemove to remove what we've done upon failure Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
854a004fd6
commit
109554d714
@ -1082,8 +1082,10 @@ int virCgroupNewDriver(const char *name,
|
||||
rc = virCgroupNew(name, rootgrp, -1, group);
|
||||
if (rc == 0) {
|
||||
rc = virCgroupMakeGroup(rootgrp, *group, create, VIR_CGROUP_NONE);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
virCgroupRemove(*group);
|
||||
virCgroupFree(group);
|
||||
}
|
||||
}
|
||||
out:
|
||||
virCgroupFree(&rootgrp);
|
||||
@ -1155,8 +1157,10 @@ int virCgroupNewDomain(virCgroupPtr driver,
|
||||
* cumulative usage that we don't need.
|
||||
*/
|
||||
rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_MEM_HIERACHY);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
virCgroupRemove(*group);
|
||||
virCgroupFree(group);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -1203,8 +1207,10 @@ int virCgroupNewVcpu(virCgroupPtr domain,
|
||||
|
||||
if (rc == 0) {
|
||||
rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
virCgroupRemove(*group);
|
||||
virCgroupFree(group);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -1244,8 +1250,10 @@ int virCgroupNewEmulator(virCgroupPtr domain,
|
||||
|
||||
if (rc == 0) {
|
||||
rc = virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
virCgroupRemove(*group);
|
||||
virCgroupFree(group);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user