From nobody Thu May 2 09:47:25 2024 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=1564734860; cv=none; d=zoho.com; s=zohoarc; b=Z1A4I6q1c/W/5SygKBmMGKkySUEhiRrTONwF0wLCuiIG+xvelMM5sUj3ZEizaQvWUFjvkT7iI0SLBIV1PuPlpy9bdrcuzugcH2oCc8FYhPDayvW0cSt+orRGAS/03KrpUceQLGfSt4kv7vdEJoPKL+5+0Tmf7vIg5P3/98lkJnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564734860; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=F56rR8kBOwcMEREeLHiF0mqJJg9ccaSFgcxBeqvsaSE=; b=UlRnTNSplIRTsRO5xLeU7wSf77I8KYGksvyusSE2v555HEXFvkYn7b7LTAl9KUSBTv4D62RWevEdSGCXUHXgYW3wNmY9lKzyOba7yDuDclE4yywTf/eZ9wheKFdthA7XTO/MMtMIgwcA7/0bxGJpxFggW+sAiR4Nrj7aHZfxbd4= 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 156473486001664.13507115954019; Fri, 2 Aug 2019 01:34:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A72E13082120; Fri, 2 Aug 2019 08:34:17 +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 947C660925; Fri, 2 Aug 2019 08:34:16 +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 F0D401806B00; Fri, 2 Aug 2019 08:34:12 +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 x728UYJ9008660 for ; Fri, 2 Aug 2019 04:30:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id D626F5D713; Fri, 2 Aug 2019 08:30:34 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 623335D712 for ; Fri, 2 Aug 2019 08:30:31 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 2 Aug 2019 10:30:30 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] vircgroup: fix partition creation for cgroups v2 without systemd 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 02 Aug 2019 08:34:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" On hosts without systemd libvirt is responsible for creating cgroups topology. With cgroups v2 the logic changed a bit. If we need to create new directory the detection of controllers fails because the directory doesn't exists so there is no cgroup.controllers file. To fix that issue we need to have a parent cgroup where we can look into cgroup.subtree_control to get a list of enabled controllers. To fix the issue reorder the operations to get a parent group fist so we can use it to create a new partition. Reported-by: Raghav Gururajan Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 825f62a97b..0789630b47 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -842,6 +842,7 @@ virCgroupNewPartition(const char *path, virCgroupPtr *group) { int ret =3D -1; + char *tmp; VIR_AUTOFREE(char *) parentPath =3D NULL; VIR_AUTOFREE(char *) newPath =3D NULL; virCgroupPtr parent =3D NULL; @@ -858,25 +859,27 @@ virCgroupNewPartition(const char *path, if (virCgroupSetPartitionSuffix(path, &newPath) < 0) goto cleanup; =20 - if (virCgroupNew(-1, newPath, NULL, controllers, group) < 0) + if (STREQ(newPath, "/")) { + ret =3D 0; goto cleanup; - - if (STRNEQ(newPath, "/")) { - char *tmp; - if (VIR_STRDUP(parentPath, newPath) < 0) - goto cleanup; - - tmp =3D strrchr(parentPath, '/'); - tmp++; - *tmp =3D '\0'; - - if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) - goto cleanup; - - if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < = 0) - goto cleanup; } =20 + if (VIR_STRDUP(parentPath, newPath) < 0) + goto cleanup; + + tmp =3D strrchr(parentPath, '/'); + tmp++; + *tmp =3D '\0'; + + if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) + goto cleanup; + + if (virCgroupNew(-1, newPath, parent, controllers, group) < 0) + goto cleanup; + + if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0) + goto cleanup; + ret =3D 0; cleanup: if (ret !=3D 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list