From nobody Sun Feb 8 11:45:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1584711641; cv=none; d=zohomail.com; s=zohoarc; b=g6UQ3BD47zYisV+TS7lGX1fuSmKd1mGm8ZfI7rdT8FdI47wVZ4dXnuF85ew3fW2LrOt1sHNFqJPwqFC1tb/OekjL8LP0xcbhFcitIQAXFDttiCXR5YlbhuzweNkrjxOrrKHQs9YaHSlN7InS4wnm6XjOP1m+Km0U7IyRMES7RWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584711641; 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; bh=SXgVZMJg2tUfZxwFXrky/SVQ3kDYmWuOdK9EkKgoFiA=; b=dpqsiR5F/HX2uHiRocqOfInCkYej+ZASTDcmqr1tmZsGZOfC9hSYSK9c4XNlepaAHUbtvfMsI3T4xvt31tq+BszZH6qbNRIxZWKITkk7wjuLOIoXydJXXNXq61UUTT6HD2KYqP3ZKIJFd06mpPmdziaRGKM00XdWrWWedjOBmnk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584711641909365.61289403078945; Fri, 20 Mar 2020 06:40:41 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-d-vyMXl4PYW2ByfRxjQH4A-1; Fri, 20 Mar 2020 09:40:38 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF30A0CC2; Fri, 20 Mar 2020 13:40:32 +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 30902BBBE8; Fri, 20 Mar 2020 13:40:32 +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 CFE2918089D7; Fri, 20 Mar 2020 13:40:31 +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 02KDeP6p020339 for ; Fri, 20 Mar 2020 09:40:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD0C66EFB0; Fri, 20 Mar 2020 13:40:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-3.ams2.redhat.com [10.36.114.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF86062937; Fri, 20 Mar 2020 13:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584711640; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SXgVZMJg2tUfZxwFXrky/SVQ3kDYmWuOdK9EkKgoFiA=; b=i4LqpQ/vJV89Z98CJOfsonFI1G3iTlR5R4s1twJ5MqVLyUXOoPhNarDM8zH0r0OANNoJM0 efJllCNoyBp7HvXBRQxrigNJ39aFJaC70NlJ46lzX8sCAS7NW9EcsNdCzMfH51tzMbtRyr PPQDRc3+Imm9TROoXoTRMyopKY2cbgU= X-MC-Unique: d-vyMXl4PYW2ByfRxjQH4A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] util: allow choice between machined or direct cgroups filesystem Date: Fri, 20 Mar 2020 13:40:12 +0000 Message-Id: <20200320134014.3123811-3-berrange@redhat.com> In-Reply-To: <20200320134014.3123811-1-berrange@redhat.com> References: <20200320134014.3123811-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The cgroups code currently tries to use machined and then falls back to using the cgroups filesystem directly. This introduces a new enum that allows callers to have explicit control over which impl is used. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/lxc/lxc_cgroup.c | 1 + src/qemu/qemu_cgroup.c | 1 + src/util/vircgroup.c | 57 ++++++++++++++++++++++++++---------------- src/util/vircgroup.h | 7 ++++++ 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 326d33981c..629f9eca1c 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -414,6 +414,7 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def, initpid, true, nnicindexes, nicindexes, + VIR_CGROUP_REGISTER_DEFAULT, def->resource->partition, -1, 0, diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index c407431f6b..cd7c381185 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -968,6 +968,7 @@ qemuInitCgroup(virDomainObjPtr vm, vm->pid, false, nnicindexes, nicindexes, + VIR_CGROUP_REGISTER_DEFAULT, vm->def->resource->partition, cfg->cgroupControllers, cfg->maxThreadsPerProc, diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 70d85200cb..0128c8bb60 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1228,6 +1228,7 @@ virCgroupNewMachine(const char *name, bool isContainer, size_t nnicindexes, int *nicindexes, + virCgroupRegister *reg, const char *partition, int controllers, unsigned int maxthreads, @@ -1237,29 +1238,43 @@ virCgroupNewMachine(const char *name, =20 *group =3D NULL; =20 - if ((rv =3D virCgroupNewMachineSystemd(name, - drivername, - uuid, - rootdir, - pidleader, - isContainer, - nnicindexes, - nicindexes, - partition, - controllers, - maxthreads, - group)) =3D=3D 0) - return 0; + if (*reg =3D=3D VIR_CGROUP_REGISTER_DEFAULT || + *reg =3D=3D VIR_CGROUP_REGISTER_MACHINED) { + if ((rv =3D virCgroupNewMachineSystemd(name, + drivername, + uuid, + rootdir, + pidleader, + isContainer, + nnicindexes, + nicindexes, + partition, + controllers, + maxthreads, + group)) =3D=3D 0) { + *reg =3D VIR_CGROUP_REGISTER_MACHINED; + return 0; + } =20 - if (rv =3D=3D -1) - return -1; + if (rv =3D=3D -1) + return -1; + + if (*reg =3D=3D VIR_CGROUP_REGISTER_MACHINED) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("Systemd machined requested, but not av= ailable")); + return -1; + } + } =20 - return virCgroupNewMachineManual(name, - drivername, - pidleader, - partition, - controllers, - group); + rv =3D virCgroupNewMachineManual(name, + drivername, + pidleader, + partition, + controllers, + group); + if (rv =3D=3D 0) + *reg =3D VIR_CGROUP_REGISTER_DIRECT; + return rv; } =20 =20 diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 1dcd0688f1..b725bc4c94 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -87,6 +87,12 @@ virCgroupNewDetectMachine(const char *name, virCgroupPtr *group) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +typedef enum { + VIR_CGROUP_REGISTER_DEFAULT, + VIR_CGROUP_REGISTER_DIRECT, + VIR_CGROUP_REGISTER_MACHINED, +} virCgroupRegister; + int virCgroupNewMachine(const char *name, const char *drivername, const unsigned char *uuid, @@ -95,6 +101,7 @@ int virCgroupNewMachine(const char *name, bool isContainer, size_t nnicindexes, int *nicindexes, + virCgroupRegister *reg, const char *partition, int controllers, unsigned int maxthreads, --=20 2.24.1