From nobody Sun Feb 8 10:33:49 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=1604407343; cv=none; d=zohomail.com; s=zohoarc; b=SNSczyKoPWVFy8i6ctcayGUkhCnxJWOwA/LV9O+6gjjF+FDtdL/knWiouD4w5q5vS3F9Q6SUA3xw0RzR45X8pF1Is8HIUbPlJrsaOjNUc03/kSC4wN97t3IVYzYuhfdW5QLixTtuypinSG5hkw2HQpL0MYzNv47DyjDg+nfdBoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407343; 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=yadB5VgpHs5atg0pa9r0zvVCZ+rNNGXN8zdNvusYbg8=; b=g6YqJXMlSpE4dwxb+uwtnNXgAtYYRnVvet63YOsOaxrNZehRhbqdda8WIneJtDWUneQrPndwqVe5RyV4xzjO4ToS0niLTUXKx5yrYGekHMPSlmrMJkRKDLaheyVT2uG33u21g0MB2Jm8HbViiTlHtXyX7uVpQ9E86c3zj7YkgtY= 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 1604407343223328.90688101800754; Tue, 3 Nov 2020 04:42:23 -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-543-oTPaqGdVN6mc9Ixg_dNtLw-1; Tue, 03 Nov 2020 07:42:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 789F010866B2; Tue, 3 Nov 2020 12:42:13 +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 55A7B7512C; Tue, 3 Nov 2020 12:42:13 +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 1AC65181A71F; Tue, 3 Nov 2020 12:42:13 +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 0A3Cfs6V015958 for ; Tue, 3 Nov 2020 07:41:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0165F73661; Tue, 3 Nov 2020 12:41:54 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 704A11C4 for ; Tue, 3 Nov 2020 12:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407342; 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=yadB5VgpHs5atg0pa9r0zvVCZ+rNNGXN8zdNvusYbg8=; b=WsLXdSqC2RRnz36JYBy0PgD4WXgJxT9gtrk6o4P7tN71f+oi0MpgCVooN2VzwiRZhtzv9n w4nTkem+0N4wYMCby2VGkWCo6f+RL0s4ERoDXbRlaFcxI6vRd/l66SHfDsZ4+FgPnFlRBI 45pAEpuXx+v9rrJU4gog9ryoHSaU6xU= X-MC-Unique: oTPaqGdVN6mc9Ixg_dNtLw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 13/25] vircgroup: extract virCgroupNewDetect from virCgroupNew Date: Tue, 3 Nov 2020 13:41:25 +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.79 on 10.5.11.15 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" The current code uses virCgroupNew() as a single point of entry and calls into virCgroupDetect() as well. Both have logic for several paths which is difficult to figure out. Extract the actually used code path from the two functions to make it obvious what's happening in this case. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index f21a581946..97e15c0ab3 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1048,7 +1048,28 @@ virCgroupNewDetect(pid_t pid, int controllers, virCgroupPtr *group) { - return virCgroupNew(pid, "", NULL, controllers, group); + g_autoptr(virCgroup) new =3D g_new0(virCgroup, 1); + + VIR_DEBUG("pid=3D%lld controllers=3D%d group=3D%p", + (long long) pid, controllers, group); + + if (virCgroupSetBackends(new) < 0) + return -1; + + if (virCgroupDetectMounts(new) < 0) + return -1; + + if (virCgroupDetectPlacement(new, pid, "") < 0) + return -1; + + if (virCgroupValidatePlacement(new, pid) < 0) + return -1; + + if (virCgroupDetectControllers(new, controllers, NULL) < 0) + return -1; + + *group =3D g_steal_pointer(&new); + return 0; } =20 =20 --=20 2.26.2