mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
vircgroup: introduce virCgroupSetBackends helper
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c88b3712ca
commit
a4353381f1
@ -212,6 +212,33 @@ virCgroupPartitionEscape(char **path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virCgroupSetBackends(virCgroupPtr group)
|
||||||
|
{
|
||||||
|
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
||||||
|
bool backendAvailable = false;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!backends)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||||
|
if (backends[i] && backends[i]->available()) {
|
||||||
|
group->backends[i] = backends[i];
|
||||||
|
backendAvailable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backendAvailable) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("no cgroup backend available"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process /proc/mounts figuring out what controllers are
|
* Process /proc/mounts figuring out what controllers are
|
||||||
* mounted and where
|
* mounted and where
|
||||||
@ -339,29 +366,14 @@ virCgroupDetect(virCgroupPtr group,
|
|||||||
virCgroupPtr parent)
|
virCgroupPtr parent)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
bool backendAvailable = false;
|
|
||||||
int controllersAvailable = 0;
|
int controllersAvailable = 0;
|
||||||
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
|
||||||
|
|
||||||
VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
|
VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
|
||||||
group, controllers, path, parent);
|
group, controllers, path, parent);
|
||||||
|
|
||||||
if (!backends)
|
if (virCgroupSetBackends(group) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
|
||||||
if (backends[i] && backends[i]->available()) {
|
|
||||||
group->backends[i] = backends[i];
|
|
||||||
backendAvailable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!backendAvailable) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("no cgroup backend available"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||||
if (group->backends[i] &&
|
if (group->backends[i] &&
|
||||||
|
Loading…
Reference in New Issue
Block a user