From nobody Sun Feb 8 10:04:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1604407334; cv=none; d=zohomail.com; s=zohoarc; b=j7W2TXZ8A/9oyUYLcURZJ7Vn2C8XahlAAExNPJcXfkoKGh7cVLxNJBZ0u+Xbf4qGwR07GJJuKPuKWoFRRc0HBzC+cNM3Eax/9DfEuEMr0iWEsvsZwfcKJylCkZNfBhRmB6iOfzEyG/RlkXzLEbRo5fZY1W9VrD8KsoXtLNm4xJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407334; 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=rT3YiOWOnH+IrH9FqtCBHMnkNSuCx7ESg5ZktvPGT6A=; b=a/fIkTGDnVd85f0V+hGx9xc1UgNYBvwy7LEBLtAe+tLejiZqd2adYDo5M9+9Fa9Jf284CtVR1JW+EPRbUZkC3qL70aRloEIwgT3UVud/6kayPe0B+YcJ+1tdpRG7CwxOaeJvsoP6F0ZivOFD0DyduQ7wTGctWcgnXkD7dj5s3UM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160440733405962.46530337503748; Tue, 3 Nov 2020 04:42:14 -0800 (PST) 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-27-DEm9VoT0OgKypveuGZ359A-1; Tue, 03 Nov 2020 07:42:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E500F1006CAE; Tue, 3 Nov 2020 12:42:04 +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 C0D8F1002C3E; Tue, 3 Nov 2020 12:42:04 +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 88CD41819AC1; Tue, 3 Nov 2020 12:42:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3Cfnob015903 for ; Tue, 3 Nov 2020 07:41:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A8AF1C4; Tue, 3 Nov 2020 12:41:49 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id E975773667 for ; Tue, 3 Nov 2020 12:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407333; 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=rT3YiOWOnH+IrH9FqtCBHMnkNSuCx7ESg5ZktvPGT6A=; b=A4fmtlmDSq8/4XxSlkMVvsRGoPido8AAlL/4x3mChm+c4aNT48VPQsowznMMlwWUQsT7i+ cgL0sSa4T8Osf3ZyVcgkqChJXVNDr1j//tMC7gLD2POKt76fWeBF7t8LnqJk8/h0QI3Kab z6o1Oo6jDaXp3JXVfTctl7t2UjmW+08= X-MC-Unique: DEm9VoT0OgKypveuGZ359A-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 08/25] vircgroup: introduce virCgroupSetBackends helper Date: Tue, 3 Nov 2020 13:41:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 7ff23e1218..3db20ed262 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -212,6 +212,33 @@ virCgroupPartitionEscape(char **path) } =20 =20 +static int +virCgroupSetBackends(virCgroupPtr group) +{ + virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); + bool backendAvailable =3D false; + size_t i; + + if (!backends) + return -1; + + for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { + if (backends[i] && backends[i]->available()) { + group->backends[i] =3D backends[i]; + backendAvailable =3D true; + } + } + + if (!backendAvailable) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("no cgroup backend available")); + return -1; + } + + return 0; +} + + /* * Process /proc/mounts figuring out what controllers are * mounted and where @@ -339,29 +366,14 @@ virCgroupDetect(virCgroupPtr group, virCgroupPtr parent) { size_t i; - bool backendAvailable =3D false; int controllersAvailable =3D 0; - virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); =20 VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", group, controllers, path, parent); =20 - if (!backends) + if (virCgroupSetBackends(group) < 0) return -1; =20 - for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { - if (backends[i] && backends[i]->available()) { - group->backends[i] =3D backends[i]; - backendAvailable =3D true; - } - } - - if (!backendAvailable) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no cgroup backend available")); - return -1; - } - if (parent) { for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (group->backends[i] && --=20 2.26.2