From nobody Sun Feb 8 19:03:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563800848; cv=none; d=zoho.com; s=zohoarc; b=OTtjhAiZkeOdU6e7zTb0Zkr27nizitZakZm+QTHMRW8Dl2JVoy8tg/jM+kHDgGOZLu86ud7pd/Z9rDgZcgwWqSvhAMiI6KaxjbnDyyJXK02/MZpBLwb+6b90fvYoXWIUY3sDCt+QEKrkBcO//iibCYrgR5fXdtSGmhCw6avEtlo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563800848; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rYQhy6tEYz25vf1oqLUyXLHhJBYPmOOF2lRjfunSwS0=; b=WE/aJmz9Vfd6PpEQRv9jmWUy6gkFU/rPA4tWYTh84UpQR1jV+ZPdRi4Qe7LX60Xt5WRaTHORVfXXjPMHrFx4RLRjAXjjb2NQdDCmCHgHkYPPFKAV3z/CKJ+gSAmWY5PxsnpK4KgqGxOFXF5X/v3IBmDgiTTPF6dxz5eJmVQOBAo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563800848172408.3226180785267; Mon, 22 Jul 2019 06:07:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0268308222F; Mon, 22 Jul 2019 13:07:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 817AE17168; Mon, 22 Jul 2019 13:07:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 173EA1800207; Mon, 22 Jul 2019 13:07:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6MD7O7h001393 for ; Mon, 22 Jul 2019 09:07:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69303BA90; Mon, 22 Jul 2019 13:07:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id E800660C64 for ; Mon, 22 Jul 2019 13:07:15 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 22 Jul 2019 15:07:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] vircgroup: fix cgroups v2 controllers detection X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 22 Jul 2019 13:07:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When creating new group for cgroups v2 the we cannot check cgroups.controllers for that cgroup because the directory is created later. In that case we should check cgroups.subtree_control of parent group to get list of controllers enabled for child cgroups. In order to achieve that we will prefer the parent group if it exists, the current group will be used only for root group. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 2 +- src/util/vircgroupbackend.h | 3 ++- src/util/vircgroupv1.c | 3 ++- src/util/vircgroupv2.c | 23 ++++++++++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index f7afc2964d..cc21758323 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -407,7 +407,7 @@ virCgroupDetect(virCgroupPtr group, =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (group->backends[i]) { - int rc =3D group->backends[i]->detectControllers(group, contro= llers); + int rc =3D group->backends[i]->detectControllers(group, contro= llers, parent); if (rc < 0) return -1; controllersAvailable |=3D rc; diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index a91719f89d..77451b0cb6 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -98,7 +98,8 @@ typedef char * =20 typedef int (*virCgroupDetectControllersCB)(virCgroupPtr group, - int controllers); + int controllers, + virCgroupPtr parent); =20 typedef bool (*virCgroupHasControllerCB)(virCgroupPtr cgroup, diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 7968ab3cf0..4231d8d6fa 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -420,7 +420,8 @@ virCgroupV1StealPlacement(virCgroupPtr group) =20 static int virCgroupV1DetectControllers(virCgroupPtr group, - int controllers) + int controllers, + virCgroupPtr parent ATTRIBUTE_UNUSED) { size_t i; size_t j; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 9d8a38925a..9c44b3473e 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -242,7 +242,8 @@ virCgroupV2StealPlacement(virCgroupPtr group) =20 =20 static int -virCgroupV2ParseControllersFile(virCgroupPtr group) +virCgroupV2ParseControllersFile(virCgroupPtr group, + virCgroupPtr parent) { int rc; VIR_AUTOFREE(char *) contStr =3D NULL; @@ -250,10 +251,17 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) char **contList =3D NULL; char **tmp; =20 - if (virAsprintf(&contFile, "%s%s/cgroup.controllers", - group->unified.mountPoint, - NULLSTR_EMPTY(group->unified.placement)) < 0) - return -1; + if (parent) { + if (virAsprintf(&contFile, "%s%s/cgroup.subtree_control", + parent->unified.mountPoint, + NULLSTR_EMPTY(parent->unified.placement)) < 0) + return -1; + } else { + if (virAsprintf(&contFile, "%s%s/cgroup.controllers", + group->unified.mountPoint, + NULLSTR_EMPTY(group->unified.placement)) < 0) + return -1; + } =20 rc =3D virFileReadAll(contFile, 1024 * 1024, &contStr); if (rc < 0) { @@ -286,11 +294,12 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) =20 static int virCgroupV2DetectControllers(virCgroupPtr group, - int controllers) + int controllers, + virCgroupPtr parent) { size_t i; =20 - if (virCgroupV2ParseControllersFile(group) < 0) + if (virCgroupV2ParseControllersFile(group, parent) < 0) return -1; =20 /* In cgroup v2 there is no cpuacct controller, the cpu.stat file alwa= ys --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list