mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
vircgroup: Try harder to kill cgroup
Prior to rewrite of cgroup code we only had one backend to try. After the rewrite the virCgroupBackendGetAll() returns both backends (for v1 and v2). However, not both have to really be present on the system which results in killRecursive callback failing which in turn might mean we won't try the other backend. At the same time, this function reports no error as it should. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
797bdb3ce8
commit
401030499b
@ -2607,6 +2607,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int rc;
|
int rc;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
bool backendAvailable = false;
|
||||||
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
||||||
virHashTablePtr pids = virHashCreateFull(100,
|
virHashTablePtr pids = virHashCreateFull(100,
|
||||||
NULL,
|
NULL,
|
||||||
@ -2617,13 +2618,9 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
|
|||||||
|
|
||||||
VIR_DEBUG("group=%p path=%s signum=%d", group, group->path, signum);
|
VIR_DEBUG("group=%p path=%s signum=%d", group, group->path, signum);
|
||||||
|
|
||||||
if (!backends) {
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||||
if (backends[i]) {
|
if (backends && backends[i] && backends[i]->available()) {
|
||||||
|
backendAvailable = true;
|
||||||
rc = backends[i]->killRecursive(group, signum, pids);
|
rc = backends[i]->killRecursive(group, signum, pids);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -2634,6 +2631,12 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!backends || !backendAvailable) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("no cgroup backend available"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virHashFree(pids);
|
virHashFree(pids);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user