From nobody Sun Feb 8 11:22:00 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=1604407385; cv=none; d=zohomail.com; s=zohoarc; b=E4G8ji3bxAnJPIH0vMF8pnhGxuORowKGot9+SRXfGUmYsaSMEdpVfk9vPPXujT9GK6jxR8A0fK4wxaii+guTTlUelDfjWqpOgt6LpfvI8Nate8wgfUqdESdLIuW1DmrUYZJJQCuGP10USPONO0w/2SyhP6xFHKsbTlOlODUW6oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407385; 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=vg3+4nUMCsovD2NBWGuKV6OyTT/cKZfrYA3SWZ438Fo=; b=hQJJeReZlNrYWwwf1dv0IE6sgQ/WanA3zoTOu4NnLBQbByzGdnvVpqu+qf2wiMDo2UQvOOIKoeBl300geMEEG32aPcU4HUCYnKQ6sr1trHeNlya0Znf9StNq8xU63Vk7JmLyEUsoCQbLD4P0YB4WlWdCNTke8DO+AkvbpikBHwc= 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 1604407385923306.0887860435132; Tue, 3 Nov 2020 04:43:05 -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-122-kNeuYaRRNkS5nH1be-Ig6w-1; Tue, 03 Nov 2020 07:42:22 -0500 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 C4D6010082EA; Tue, 3 Nov 2020 12:42:15 +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 A619B73667; Tue, 3 Nov 2020 12:42:15 +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 738058C7DE; Tue, 3 Nov 2020 12:42:15 +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 0A3Cg1qQ016047 for ; Tue, 3 Nov 2020 07:42:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 130E573664; Tue, 3 Nov 2020 12:42:01 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8042E1C4 for ; Tue, 3 Nov 2020 12:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407384; 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=vg3+4nUMCsovD2NBWGuKV6OyTT/cKZfrYA3SWZ438Fo=; b=HAF22HRxbSFTemv52lvv8TyFu2Vi0AbbO2Ev1wBrIkqGDUhQouJdiBeoKln3Ym9cSzTUso VG8jhMOSR1fjb+PiidKUoewX/V4T1EYckQ+IOvP6AeoKIzugdNWqBvAQ6MicEZyiQ4iOvZ 2Jj3IGpdaBUn/XhMzFLFKIWkT+QHNWY= X-MC-Unique: kNeuYaRRNkS5nH1be-Ig6w-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 17/25] vircgroup: expand virCgroupDetect into virCgroupNew Date: Tue, 3 Nov 2020 13:41:29 +0100 Message-Id: <9fd88498e7a44267d07bfb7a150ce60594dbacca.1604407065.git.phrdina@redhat.com> 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.79 on 10.5.11.13 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 | 52 +++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 794680d696..81aa3ee791 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -442,39 +442,6 @@ virCgroupDetectControllers(virCgroupPtr group, } =20 =20 -static int -virCgroupDetect(virCgroupPtr group, - pid_t pid, - int controllers, - const char *path) -{ - VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s", - group, controllers, path); - - if (virCgroupSetBackends(group) < 0) - return -1; - - if (virCgroupDetectMounts(group) < 0) - return -1; - - if (virCgroupCopyPlacement(group, path, NULL) < 0) - return -1; - - /* ... but use /proc/cgroups to fill in the rest */ - if (virCgroupDetectPlacement(group, pid, path) < 0) - return -1; - - /* Check that for every mounted controller, we found our placement */ - if (virCgroupValidatePlacement(group, pid) < 0) - return -1; - - if (virCgroupDetectControllers(group, controllers, NULL) < 0) - return -1; - - return 0; -} - - char * virCgroupGetBlockDevString(const char *path) { @@ -717,7 +684,24 @@ virCgroupNew(pid_t pid, *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); =20 - if (virCgroupDetect(newGroup, pid, controllers, path) < 0) + if (virCgroupSetBackends(newGroup) < 0) + return -1; + + if (virCgroupDetectMounts(newGroup) < 0) + return -1; + + if (virCgroupCopyPlacement(newGroup, path, NULL) < 0) + return -1; + + /* ... but use /proc/cgroups to fill in the rest */ + if (virCgroupDetectPlacement(newGroup, pid, path) < 0) + return -1; + + /* Check that for every mounted controller, we found our placement */ + if (virCgroupValidatePlacement(newGroup, pid) < 0) + return -1; + + if (virCgroupDetectControllers(newGroup, controllers, NULL) < 0) return -1; =20 *group =3D g_steal_pointer(&newGroup); --=20 2.26.2