From nobody Sun Feb 8 17:04:28 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=1561461447; cv=none; d=zoho.com; s=zohoarc; b=KuP6HxvMNlKfOd7nnugsO2V/y8wHOFsIwhzVpFj9ssA+C75G2I7Mb+hiSbRPvGcjA1cw1Ksy/TpfTZpZcZtKxJe0I1M6rOh/YPOnpMlkVuvXsiAaBXKQM6EQE56bUug/B2A9mwTA/vVXQagQgubEwybaKpbJg6bDny0R6/U4Zts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561461447; 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=u8RdzsT8QnerQbtYQpxbU3bY1xqVGCeZw8eqHa7gars=; b=YqY4M2/Ea4aO4KAI+BHGiqHgbVN8JmPBC1nWFl35ayePHgbLyWsBoFUvSz6etTGPVYvH38l11D66yR5vu+WXBRCSkH/tBVCn5SzsvgfWJKBBGnIon2CSAvY716s4p7dZqtR51RueqXgguRLQcL4lVERrYP0fxJDaTkoKf9NkfaY= 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 156146144741627.057795414627094; Tue, 25 Jun 2019 04:17:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83B6B368E6; Tue, 25 Jun 2019 11:17:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58BC419728; Tue, 25 Jun 2019 11:17:24 +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 384AB206D4; Tue, 25 Jun 2019 11:17:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5PBGVd3029355 for ; Tue, 25 Jun 2019 07:16:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCB6B5D71B; Tue, 25 Jun 2019 11:16:31 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65A545D717 for ; Tue, 25 Jun 2019 11:16:31 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 25 Jun 2019 13:16:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 2/7] util: vircgroup: improve controller 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 25 Jun 2019 11:17:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This affects only cgroups v2 where enabled controllers are not based on available mount points but on the list provided in cgroup.controllers file. However, moving it will fill in placement as well, so it needs to be freed together with mount point if we don't need that controller. Before this patch we were assuming that all controllers available in root cgroup where available in all other sub-cgroups which was wrong. In order to fix it we need to move the cgroup controllers detection after cgroup placement was prepared in order to build correct path for cgroup.controllers file. Signed-off-by: Pavel Hrdina --- Notes: Changes in v3: - Moving the detection after placement means we need to free it together with mount point if that controller is not required. src/util/vircgroup.c | 32 ++++++++++++++++---------------- src/util/vircgroupv1.c | 1 + src/util/vircgroupv2.c | 5 +++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index b7e5f03521..da506fc0b0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -381,22 +381,6 @@ virCgroupDetect(virCgroupPtr group, return -1; } =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, parent); - if (rc < 0) - return -1; - controllersAvailable |=3D rc; - } - } - - /* Check that at least 1 controller is available */ - if (controllersAvailable =3D=3D 0) { - virReportSystemError(ENXIO, "%s", - _("At least one cgroup controller is required= ")); - return -1; - } - /* In some cases we can copy part of the placement info * based on the parent cgroup... */ @@ -421,6 +405,22 @@ 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, parent); + if (rc < 0) + return -1; + controllersAvailable |=3D rc; + } + } + + /* Check that at least 1 controller is available */ + if (controllersAvailable =3D=3D 0) { + virReportSystemError(ENXIO, "%s", + _("At least one cgroup controller is required= ")); + return -1; + } + return 0; } =20 diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index fb3e0b2d47..4231d8d6fa 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -464,6 +464,7 @@ virCgroupV1DetectControllers(virCgroupPtr group, } } VIR_FREE(group->legacy[i].mountPoint); + VIR_FREE(group->legacy[i].placement); } } } else { diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 2d09d77a29..29b5806a01 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -250,8 +250,9 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) char **contList =3D NULL; char **tmp; =20 - if (virAsprintf(&contFile, "%s/cgroup.controllers", - group->unified.mountPoint) < 0) + 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); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list