for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
if (group->backends[i]) {
- int rc = group->backends[i]->detectControllers(group, controllers, parent);
+ int rc = group->backends[i]->detectControllers(group, controllers, parent,
+ controllersAvailable);
if (rc < 0)
return -1;
controllersAvailable |= rc;
static int
virCgroupV1DetectControllers(virCgroupPtr group,
int controllers,
- virCgroupPtr parent G_GNUC_UNUSED)
+ virCgroupPtr parent G_GNUC_UNUSED,
+ int detected)
{
size_t i;
size_t j;
/* First mark requested but non-existing controllers to be ignored */
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (((1 << i) & controllers)) {
+ int type = 1 << i;
+ if (type & detected) {
+ VIR_FREE(group->legacy[i].mountPoint);
+ VIR_FREE(group->legacy[i].placement);
+ }
/* Remove non-existent controllers */
if (!group->legacy[i].mountPoint) {
VIR_DEBUG("Requested controller '%s' not mounted, ignoring",
VIR_DEBUG("Auto-detecting controllers");
controllers = 0;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ int type = 1 << i;
+ if (type & detected) {
+ VIR_FREE(group->legacy[i].mountPoint);
+ VIR_FREE(group->legacy[i].placement);
+ }
VIR_DEBUG("Controller '%s' present=%s",
virCgroupV1ControllerTypeToString(i),
group->legacy[i].mountPoint ? "yes" : "no");
static int
virCgroupV2DetectControllers(virCgroupPtr group,
int controllers,
- virCgroupPtr parent)
+ virCgroupPtr parent,
+ int detected)
{
size_t i;
if (controllers >= 0)
group->unified.controllers &= controllers;
+ group->unified.controllers &= ~detected;
+
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++)
VIR_DEBUG("Controller '%s' present=%s",
virCgroupV2ControllerTypeToString(i),