From nobody Mon Feb 9 13:59:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612877210; cv=none; d=zohomail.com; s=zohoarc; b=AVX1Z+h+/pKZV9PsUx2WANJwnXglzXevSSp7701m0OMOyhowwV30+ubBRBm87bj1BNDsw7iJuplTG4gy6R6gxACX2AjbKNgRjpzCJQ9lWT9M+Rk+mccdK3xmIL242aBXTAK9ItVHUeQTJAIodigH6Klqp0neEKavNElu2FYUivs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612877210; 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=PaIyRBhONHwhZdcwkY/g2X2Ns40vPYQYNxslLAqzTSU=; b=dOh5bAzW7kl3qCv4O3+9sBskQkr0g92hGNR2xICPgZt4uJtMy6UO1r/2SyJMEJ7WvPU6F2mldvAFS/jSgkoVeoQwb00QxtKnKjUctS9MYO+wim73NEuUB2er8auewOUFm6lwNL1TojQFdbxPgpmiGMAhQqn8v02g0OsLrXoN9eY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612877210689459.0053502564401; Tue, 9 Feb 2021 05:26:50 -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-384-REURWnifP5uhQaZQYJ_SNA-1; Tue, 09 Feb 2021 08:26:47 -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 31AD9801979; Tue, 9 Feb 2021 13:26:41 +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 0BFA110016F6; Tue, 9 Feb 2021 13:26:41 +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 C788918089D3; Tue, 9 Feb 2021 13:26:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 119DQPBS020434 for ; Tue, 9 Feb 2021 08:26:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1BC8C5D9CD; Tue, 9 Feb 2021 13:26:25 +0000 (UTC) Received: from antique-laptop.redhat.com (unknown [10.40.208.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6955E5D9C0 for ; Tue, 9 Feb 2021 13:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612877209; 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=PaIyRBhONHwhZdcwkY/g2X2Ns40vPYQYNxslLAqzTSU=; b=MzecAygmefZsx4MSZCfM/T5WFM7gd06nbblUPYr3oAf6UwhV/467T1hM3zqxqcQD6y2P6H v67H3ttTPy58o9QqOnzPohKszabmY1gSqnosyqggDh0IhMkr+EtayioIanIlOAIs/aRS0o jFZzqMI69kLjogkKv3y9T9ucpgctFdg= X-MC-Unique: REURWnifP5uhQaZQYJ_SNA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] vircgroupv1: refactor virCgroupV1DetectPlacement Date: Tue, 9 Feb 2021 14:26:10 +0100 Message-Id: <141f9ef312577b2b085c9eb6469148462be7a51b.1612875677.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" Remove one level of indentation by splitting the condition. Signed-off-by: Pavel Hrdina --- src/util/vircgroupv1.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index edb2c23bbc..f4dd20fd73 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -339,23 +339,28 @@ virCgroupV1DetectPlacement(virCgroupPtr group, for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { const char *typestr =3D virCgroupV1ControllerTypeToString(i); =20 - if (virCgroupV1MountOptsMatchController(controllers, typestr) && - group->legacy[i].mountPoint !=3D NULL && - group->legacy[i].placement =3D=3D NULL) { - /* - * selfpath =3D=3D "/" + path=3D"" -> "/" - * selfpath =3D=3D "/libvirt.service" + path =3D=3D "" -> "/li= bvirt.service" - * selfpath =3D=3D "/libvirt.service" + path =3D=3D "foo" -> "= /libvirt.service/foo" - */ - if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) { - group->legacy[i].placement =3D g_strdup(selfpath); - } else { - bool delim =3D STREQ(selfpath, "/") || STREQ(path, ""); + if (!virCgroupV1MountOptsMatchController(controllers, typestr)) + continue; =20 - group->legacy[i].placement =3D g_strdup_printf("%s%s%s", s= elfpath, - delim ? "" : = "/", - path); - } + if (!group->legacy[i].mountPoint) + continue; + + if (group->legacy[i].placement) + continue; + + /* + * selfpath =3D=3D "/" + path=3D"" -> "/" + * selfpath =3D=3D "/libvirt.service" + path =3D=3D "" -> "/libvir= t.service" + * selfpath =3D=3D "/libvirt.service" + path =3D=3D "foo" -> "/lib= virt.service/foo" + */ + if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) { + group->legacy[i].placement =3D g_strdup(selfpath); + } else { + bool delim =3D STREQ(selfpath, "/") || STREQ(path, ""); + + group->legacy[i].placement =3D g_strdup_printf("%s%s%s", selfp= ath, + delim ? "" : "/", + path); } } =20 --=20 2.29.2