From nobody Mon May 6 16:19:57 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=1561645587; cv=none; d=zoho.com; s=zohoarc; b=UtGW9qYzOLJKb4wAQ5FPnb8GbBl2wLrAyE50CC/TI2fn9JNDXJk+QdmOinM58dlecDyhrc1BSilVyq7vGofZ+ZxkXbge812JZHPAHqd7DiuSId3VctkdrDSrTrJhq1BwuWdcROq1xxhTi9U09ZldTfB8FHhvJViM+fP5O3T/KiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561645587; 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=AIycef2TIVdR7I11kyhj493HPkNt4QMJECC7AuO8Njc=; b=SFOApbw4qe3cLdjnFP7kpHkhJHf97l1chh81I0KwGO1w58ZVO1VmXtFL3yj0Ser6k8FwvSS1AHpC47wl3yznXEpaAS/l0kmvA/pyavOpa3lPCe9Lvu8L0+N6//mbdtoanAXFuNwHNA84wASGoFpzvM5tni3SSRWBg8hP5I7kGG4= 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 1561645587309539.1012689807629; Thu, 27 Jun 2019 07:26: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 7B93D308792D; Thu, 27 Jun 2019 14:26:06 +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 3E74519C4F; Thu, 27 Jun 2019 14:26:03 +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 A68491806B18; Thu, 27 Jun 2019 14:26:00 +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 x5REInk4007956 for ; Thu, 27 Jun 2019 10:18:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BE6A60BE5; Thu, 27 Jun 2019 14:18:49 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2473260BE0 for ; Thu, 27 Jun 2019 14:18:48 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 27 Jun 2019 16:18:46 +0200 Message-Id: <68334eba6526a4b7499438bb99af585035daf1e7.1561645070.git.phrdina@redhat.com> 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/2] Revert "util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB" 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.45]); Thu, 27 Jun 2019 14:26:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This reverts commit 7bca1c9bdc85247446129f856e27c80a32819e17. As it turns out it's not a good idea on systemd hosts. The root cgroup can have all controllers enabled but they don't have to be enabled for sub-cgroups. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/util/vircgroup.c | 2 +- src/util/vircgroupbackend.h | 3 +-- src/util/vircgroupv1.c | 3 +-- src/util/vircgroupv2.c | 17 ++++++----------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index da506fc0b0..e4675a0977 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, parent); + int rc =3D group->backends[i]->detectControllers(group, contro= llers); if (rc < 0) return -1; controllersAvailable |=3D rc; diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index 1fe0851184..e58e327c68 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -95,8 +95,7 @@ typedef char * =20 typedef int (*virCgroupDetectControllersCB)(virCgroupPtr group, - int controllers, - virCgroupPtr parent); + int controllers); =20 typedef bool (*virCgroupHasControllerCB)(virCgroupPtr cgroup, diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 4231d8d6fa..7968ab3cf0 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -420,8 +420,7 @@ virCgroupV1StealPlacement(virCgroupPtr group) =20 static int virCgroupV1DetectControllers(virCgroupPtr group, - int controllers, - virCgroupPtr parent ATTRIBUTE_UNUSED) + int controllers) { size_t i; size_t j; diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 502afb0b56..b3297dbb13 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -286,21 +286,16 @@ virCgroupV2ParseControllersFile(virCgroupPtr group) =20 static int virCgroupV2DetectControllers(virCgroupPtr group, - int controllers, - virCgroupPtr parent) + int controllers) { size_t i; =20 - if (parent) { - group->unified.controllers =3D parent->unified.controllers; - } else { - if (virCgroupV2ParseControllersFile(group) < 0) - return -1; + if (virCgroupV2ParseControllersFile(group) < 0) + return -1; =20 - /* In cgroup v2 there is no cpuacct controller, the cpu.stat file = always - * exists with usage stats. */ - group->unified.controllers |=3D 1 << VIR_CGROUP_CONTROLLER_CPUACCT; - } + /* In cgroup v2 there is no cpuacct controller, the cpu.stat file alwa= ys + * exists with usage stats. */ + group->unified.controllers |=3D 1 << VIR_CGROUP_CONTROLLER_CPUACCT; =20 if (controllers >=3D 0) group->unified.controllers &=3D controllers; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 16:19:57 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=1561645587; cv=none; d=zoho.com; s=zohoarc; b=cpusk41H9Q06b/QaD+uRiaZRS0LGEoP6piYZ0PwofrKbfHKM+YrJYyYFH/7N1GkaODORgJQSLqJWcMInbhFtjRB3h9RA3gTisL9Nn2VcLrDirGWuLmTqsuJpSrbGO/652xJWcpMxIsDbCbK2nAmBUj6CBgmbJS+LqswG57gvfQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561645587; 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=HUMpJpNhpWt2BSteCtAutATOA5l03giB8uJ44lR0VFM=; b=a5NOrzkQC3NdlKGjF1bhgVCC3+rviLd0pRkYxhNthrJsDjrb0vGCI2C9qIIPe1xzaPH4lprwuGFxteP6B4gb3adtBx+Eq8+56IxXuX/frQhI/GhgcqB1qryO6CgSbCdpA1Jlrg/IAY9cfcLgpfqs0ZSMDskafD1nAbZh/dybEOE= 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 1561645587039363.8644788171372; Thu, 27 Jun 2019 07:26:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D734F5D60F; Thu, 27 Jun 2019 14:26:11 +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 9964960126; Thu, 27 Jun 2019 14:26:10 +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 2476D1806B18; Thu, 27 Jun 2019 14:26:07 +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 x5REIoJT007983 for ; Thu, 27 Jun 2019 10:18:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6663360C62; Thu, 27 Jun 2019 14:18:50 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6C3160BE0 for ; Thu, 27 Jun 2019 14:18:49 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 27 Jun 2019 16:18:47 +0200 Message-Id: <168063fea7cb23952f6348df4766fd1e9c03e6ab.1561645070.git.phrdina@redhat.com> 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 2/2] util: vircgroupv2: stop enabling missing controllers with 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 27 Jun 2019 14:26:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Because of a systemd delegation policy [1] we should not write to any cgroups files owned by systemd which in case of cgroups v2 includes 'cgroups.subtree_control'. systemd will enable controllers automatically for us to have them available for VM cgroups. [1] Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/util/vircgroup.c | 2 +- src/util/vircgroupbackend.h | 3 +++ src/util/vircgroupv2.c | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index e4675a0977..268e4013e3 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1082,7 +1082,7 @@ virCgroupEnableMissingControllers(char *path, &tmp) < 0) goto cleanup; =20 - if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_NONE) < 0) { + if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_SYSTEMD) < 0)= { virCgroupFree(&tmp); goto cleanup; } diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index e58e327c68..a91719f89d 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -34,6 +34,9 @@ typedef enum { * attaching tasks */ VIR_CGROUP_THREAD =3D 1 << 1, /* cgroup v2 handles threads differently= */ + VIR_CGROUP_SYSTEMD =3D 1 << 2, /* with systemd and cgroups v2 we cannot + * manually enable controllers that syste= md + * doesn't know how to delegate */ } virCgroupBackendFlags; =20 typedef enum { diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index b3297dbb13..9d8a38925a 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -395,6 +395,11 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNU= SED, VIR_AUTOFREE(char *) path =3D NULL; int controller; =20 + if (flags & VIR_CGROUP_SYSTEMD) { + VIR_DEBUG("Running with systemd so we should not create cgroups ou= rselves."); + return 0; + } + VIR_DEBUG("Make group %s", group->path); =20 controller =3D virCgroupV2GetAnyController(group); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list