mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-30 17:45:23 +00:00
Ensure LXC container exits if cgroups setup fails
The code setting up LXC cgroups used an 'rc' variable both
for capturing the return value of methods it calls, and
its own return status. The result was that several failures
in setting up cgroups would actually result in success being
returned.
Use a separate 'ret' for tracking return value as per normal
code design in other parts of libvirt
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 8e1f0c38fa
)
This commit is contained in:
parent
bf8efc3398
commit
7e3b1283f1
@ -224,7 +224,8 @@ int virLXCCgroupSetup(virDomainDefPtr def)
|
|||||||
{
|
{
|
||||||
virCgroupPtr driver = NULL;
|
virCgroupPtr driver = NULL;
|
||||||
virCgroupPtr cgroup = NULL;
|
virCgroupPtr cgroup = NULL;
|
||||||
int rc = -1;
|
int ret = -1;
|
||||||
|
int rc;
|
||||||
|
|
||||||
rc = virCgroupForDriver("lxc", &driver, 1, 0);
|
rc = virCgroupForDriver("lxc", &driver, 1, 0);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
@ -234,7 +235,7 @@ int virLXCCgroupSetup(virDomainDefPtr def)
|
|||||||
|
|
||||||
virReportSystemError(-rc, "%s",
|
virReportSystemError(-rc, "%s",
|
||||||
_("Unable to get cgroup for driver"));
|
_("Unable to get cgroup for driver"));
|
||||||
return rc;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = virCgroupForDomain(driver, def->name, &cgroup, 1);
|
rc = virCgroupForDomain(driver, def->name, &cgroup, 1);
|
||||||
@ -262,11 +263,14 @@ int virLXCCgroupSetup(virDomainDefPtr def)
|
|||||||
virReportSystemError(-rc,
|
virReportSystemError(-rc,
|
||||||
_("Unable to add task %d to cgroup for domain %s"),
|
_("Unable to add task %d to cgroup for domain %s"),
|
||||||
getpid(), def->name);
|
getpid(), def->name);
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCgroupFree(&cgroup);
|
virCgroupFree(&cgroup);
|
||||||
virCgroupFree(&driver);
|
virCgroupFree(&driver);
|
||||||
|
|
||||||
return rc;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user