From nobody Sun Feb 8 16:34:01 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=1604407384; cv=none; d=zohomail.com; s=zohoarc; b=G9wB70iTdPnMWKW9tV+M+UyWHTHZyp6kZe7bn+bx6la7xQIzjSYpTFzcbN8uuTLkfTw6laOCZSegaAUdBgzqfshfU8PXgMxbfMRniJ363y2H0hbQqNaqbdEcm31ZaedWbhRY/BAwVGgdH9lhjMp1WIveZMNCng7FTpVQNyj8DWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407384; 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=ZJoJx8w0DpzgMDQbp1gZgpR8+y64HjznLqKqajtNI6o=; b=GKXwTZeP+s3xHnCxFZPLKPLT7N74HmimT2qzcNKG5JGGuJfj1bI6+dUZF9gu1ECXzuCCM8VEWEeNuRS4QjS63lcUMD2f83KfmndFf0SbH/8F8aK12FnhHvkAmWYWGCXZQGLLHPlLo2Xsm5hDqxzbJSzfrZ3iuS9Qw2dAI+B5uwA= 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 1604407384397560.3099066805469; Tue, 3 Nov 2020 04:43:04 -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-460-tb_LcZ-JM3WF1dnYBsiwWw-1; Tue, 03 Nov 2020 07:42:22 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E882510866A9; 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 BB0E021E8C; 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 82FB08C7DD; 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 0A3Cg7NL016318 for ; Tue, 3 Nov 2020 07:42:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F81273667; Tue, 3 Nov 2020 12:42:07 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id CECF173664 for ; Tue, 3 Nov 2020 12:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407383; 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=ZJoJx8w0DpzgMDQbp1gZgpR8+y64HjznLqKqajtNI6o=; b=Gd/dgRy8ujgcCf2CAO0DiEpWKFcChz1d0MlZAmeNHW5Fpy7JEx9UaV3vozozZPMVJzzYSB dCL0mKWTz4tUVKSDJK2bEcKp8oH8qIsj2QEOmUTm0OydL1bbCfcW4hzMJMWEMFBPP5KTZ1 9ZYY9r8eVdTHqiIfQwF1AFCThWAn2do= X-MC-Unique: tb_LcZ-JM3WF1dnYBsiwWw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 24/25] vircgroup: refactor virCgroupNewPartition Date: Tue, 3 Nov 2020 13:41:36 +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.23 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 old code passed an absolute path to virCgroupNewFromParent() which is not necessary. The code can take the current placement of parent cgroup and append a relative path. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6caeb2d7f4..e0fe1dbf3e 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -896,6 +896,7 @@ virCgroupNewPartition(const char *path, g_autofree char *newPath =3D NULL; g_autoptr(virCgroup) parent =3D NULL; g_autoptr(virCgroup) newGroup =3D NULL; + char *partition =3D NULL; =20 VIR_DEBUG("path=3D%s create=3D%d controllers=3D%x", path, create, controllers); @@ -914,17 +915,26 @@ virCgroupNewPartition(const char *path, =20 if (STRNEQ(newPath, "/")) { char *tmp; - g_autofree char *parentPath =3D g_strdup(newPath); + const char *parentPath; =20 - tmp =3D strrchr(parentPath, '/'); - tmp++; + tmp =3D strrchr(newPath, '/'); *tmp =3D '\0'; =20 + if (tmp =3D=3D newPath) { + parentPath =3D "/"; + } else { + parentPath =3D newPath; + } + if (virCgroupNew(parentPath, controllers, &parent) < 0) return -1; + + partition =3D tmp + 1; + } else { + partition =3D newPath; } =20 - if (virCgroupNewFromParent(parent, newPath, controllers, &newGroup) < = 0) + if (virCgroupNewFromParent(parent, partition, controllers, &newGroup) = < 0) return -1; =20 if (parent) { --=20 2.26.2