From nobody Sun Feb 8 12:20:37 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=1604407624; cv=none; d=zohomail.com; s=zohoarc; b=RUDELQ+FoWdU4OUjHyceTmE0UQWiFUcWdjSpukWeY90D/gMD5h0SAK2yhBmxlaYFifv6TYxcg/EUKTz7mfgGzVDA4/0TJ3gkowjYHci3s5ULqOwH8nEx4lFyOsWtSZAs4uGwP67m/iXkMPQapzFihKlhf/GKspNRtPSyliHgl3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604407624; 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=X0CaoNLhj5Rt96jphoBCbK1DboZD3d6RrWMQYak5oEA=; b=H9nStcOTq9acR5wWzVmzT2b5yiQ8bM79OmtmtN/2XFRYDOCM1EAHz38c2jN44HzEG6vq4G8ZLe/rYDSJRfD2YjW9KhK3VebhrjolBXMxPEPrK+d+sW3WxkR4xSuuZQHhrT2O9w2bvjeqolsR4hsOOZ7x3XCDQHGfQfzbcYXOVuE= 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 1604407624107191.03847848890325; Tue, 3 Nov 2020 04:47: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-414-ZqGXCQHiPXOWU6q4o9ijbA-1; Tue, 03 Nov 2020 07:42:13 -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 9F1A5803F76; Tue, 3 Nov 2020 12:42:07 +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 7F01573667; Tue, 3 Nov 2020 12:42:07 +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 4A9DC181A07C; Tue, 3 Nov 2020 12:42:07 +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 0A3CfmKR015886 for ; Tue, 3 Nov 2020 07:41:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 92E2373661; Tue, 3 Nov 2020 12:41:48 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1BB1C4 for ; Tue, 3 Nov 2020 12:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604407623; 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=X0CaoNLhj5Rt96jphoBCbK1DboZD3d6RrWMQYak5oEA=; b=e4p3rGzeJDeYmjCqRfGeZrgxl3NeMUZlnIoxIdF+x7/b6bl5e0PQAJC/8SOlK7LvWMMIsE KIKrD0Vm2F3TR6ohiVFa1dYZmuUrfy8d2xjUGC2uICMUUL1YEKnAv24xuk/S8oHjyAV/+A Ong/Yn1mrMxUHtqwgqofAaf6TSnEoNg= X-MC-Unique: ZqGXCQHiPXOWU6q4o9ijbA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 07/25] vircgroup: remove useless cgroup->path variable Date: Tue, 3 Nov 2020 13:41:19 +0100 Message-Id: <33286e83c4bc89faedd6f761fe31b6465ad8b33b.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" It is only used for debug and error purposes which can be easily replaced by @placement. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 20 ++++++-------------- src/util/vircgrouppriv.h | 2 -- src/util/vircgroupv1.c | 8 +++----- src/util/vircgroupv2.c | 4 +--- tests/vircgrouptest.c | 29 ++++++++++------------------- 5 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index e3c45e93cb..7ff23e1218 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -669,13 +669,6 @@ virCgroupNew(pid_t pid, *group =3D NULL; newGroup =3D g_new0(virCgroup, 1); =20 - if (path[0] =3D=3D '/' || !parent) { - newGroup->path =3D g_strdup(path); - } else { - newGroup->path =3D g_strdup_printf("%s%s%s", parent->path, - STREQ(parent->path, "") ? "" : "/= ", path); - } - if (virCgroupDetect(newGroup, pid, controllers, path, parent) < 0) return -1; =20 @@ -2388,8 +2381,8 @@ virCgroupKillInternal(virCgroupPtr group, g_autofree char *keypath =3D NULL; bool done =3D false; FILE *fp =3D NULL; - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", - group, group->path, signum, pids); + VIR_DEBUG("group=3D%p signum=3D%d pids=3D%p", + group, signum, pids); =20 if (virCgroupPathOfController(group, controller, taskFile, &keypath) <= 0) return -1; @@ -2471,8 +2464,8 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, g_autoptr(DIR) dp =3D NULL; struct dirent *ent; int direrr; - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", - group, group->path, signum, pids); + VIR_DEBUG("group=3D%p signum=3D%d pids=3D%p", + group, signum, pids); =20 if (virCgroupPathOfController(group, controller, "", &keypath) < 0) return -1; @@ -2532,7 +2525,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum) virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); g_autoptr(GHashTable) pids =3D g_hash_table_new_full(g_int64_hash, g_i= nt64_equal, g_free, NULL); =20 - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d", group, group->path, sign= um); + VIR_DEBUG("group=3D%p signum=3D%d", group, signum); =20 for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (backends && backends[i] && backends[i]->available()) { @@ -2563,7 +2556,7 @@ virCgroupKillPainfully(virCgroupPtr group) { size_t i; int ret; - VIR_DEBUG("cgroup=3D%p path=3D%s", group, group->path); + VIR_DEBUG("cgroup=3D%p", group); for (i =3D 0; i < 15; i++) { int signum; if (i =3D=3D 0) @@ -3491,7 +3484,6 @@ virCgroupFree(virCgroupPtr group) VIR_FREE(group->unified.mountPoint); VIR_FREE(group->unified.placement); =20 - VIR_FREE(group->path); VIR_FREE(group); } =20 diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index f85a36efdb..af8bf99888 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -60,8 +60,6 @@ typedef struct _virCgroupV2Controller virCgroupV2Controll= er; typedef virCgroupV2Controller *virCgroupV2ControllerPtr; =20 struct _virCgroup { - char *path; - virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST]; =20 virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST]; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 61fb359f8d..6bb819410b 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -545,7 +545,9 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent, "cpuset.memory_migrate", }; =20 - VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path= ); + VIR_DEBUG("Setting up inheritance %s -> %s", + parent->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement, + group->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement); for (i =3D 0; i < G_N_ELEMENTS(inherit_values); i++) { g_autofree char *value =3D NULL; =20 @@ -583,7 +585,6 @@ virCgroupV1SetMemoryUseHierarchy(virCgroupPtr group) if (value =3D=3D 1) return 0; =20 - VIR_DEBUG("Setting up %s/%s", group->path, filename); if (virCgroupSetValueU64(group, VIR_CGROUP_CONTROLLER_MEMORY, filename, 1) < 0) @@ -601,7 +602,6 @@ virCgroupV1MakeGroup(virCgroupPtr parent, { size_t i; =20 - VIR_DEBUG("Make group %s", group->path); for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { g_autofree char *path =3D NULL; =20 @@ -671,7 +671,6 @@ virCgroupV1Remove(virCgroupPtr group) int rc =3D 0; size_t i; =20 - VIR_DEBUG("Removing cgroup %s", group->path); for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { g_autofree char *grppath =3D NULL; =20 @@ -697,7 +696,6 @@ virCgroupV1Remove(virCgroupPtr group) VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath); rc =3D virCgroupRemoveRecursively(grppath); } - VIR_DEBUG("Done removing cgroup %s", group->path); =20 return rc; } diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 530e5d2ce9..0467a72566 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -413,8 +413,6 @@ virCgroupV2MakeGroup(virCgroupPtr parent, return 0; } =20 - VIR_DEBUG("Make group %s", group->path); - controller =3D virCgroupV2GetAnyController(group); if (virCgroupV2PathOfController(group, controller, "", &path) < 0) return -1; @@ -424,7 +422,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent, if (!virFileExists(path) && (!create || (mkdir(path, 0755) < 0 && errno !=3D EEXIST))) { virReportSystemError(errno, _("Failed to create v2 cgroup '%s'"), - group->path); + path); return -1; } =20 diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 6c1a766fa2..0dd5e3f0b4 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -38,7 +38,6 @@ VIR_LOG_INIT("tests.cgrouptest"); =20 static int validateCgroup(virCgroupPtr cgroup, - const char *expectPath, const char **expectMountPoint, const char **expectLinkPoint, const char **expectPlacement, @@ -48,12 +47,6 @@ static int validateCgroup(virCgroupPtr cgroup, { size_t i; =20 - if (STRNEQ(cgroup->path, expectPath)) { - fprintf(stderr, "Wrong path '%s', expected '%s'\n", - cgroup->path, expectPath); - return -1; - } - for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { if (STRNEQ_NULLABLE(expectMountPoint[i], cgroup->legacy[i].mountPoint)) { @@ -240,7 +233,7 @@ static int testCgroupNewForSelf(const void *args G_GNUC= _UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mountsFull, links, placement, NULL, = NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placement, NULL, NULL= , 0); } =20 =20 @@ -314,14 +307,14 @@ static int testCgroupNewForPartition(const void *args= G_GNUC_UNUSED) fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv= ); return -1; } - rv =3D validateCgroup(cgroup, "/virtualmachines.partition", mountsSmal= l, links, placementSmall, NULL, NULL, 0); + rv =3D validateCgroup(cgroup, mountsSmall, links, placementSmall, NULL= , NULL, 0); virCgroupFree(cgroup); =20 if ((rv =3D virCgroupNewPartition("/virtualmachines", true, -1, &cgrou= p)) !=3D 0) { fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv= ); return -1; } - return validateCgroup(cgroup, "/virtualmachines.partition", mountsFull= , links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -365,8 +358,7 @@ static int testCgroupNewForPartitionNested(const void *= args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "/deployment.partition/production.partit= ion", - mountsFull, links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -416,8 +408,7 @@ static int testCgroupNewForPartitionNestedDeep(const vo= id *args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "/user/berrange.user/production.partitio= n", - mountsFull, links, placementFull, NULL, NULL, 0); + return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, = NULL, 0); } =20 =20 @@ -448,7 +439,7 @@ static int testCgroupNewForPartitionDomain(const void *= args G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(domaincgroup, "/production.partition/foo.libvirt= -lxc", mountsFull, links, placement, NULL, NULL, 0); + return validateCgroup(domaincgroup, mountsFull, links, placement, NULL= , NULL, 0); } =20 static int testCgroupNewForPartitionDomainEscaped(const void *args G_GNUC_= UNUSED) @@ -493,7 +484,7 @@ static int testCgroupNewForPartitionDomainEscaped(const= void *args G_GNUC_UNUSED * since our fake /proc/cgroups pretends this controller * isn't compiled into the kernel */ - return validateCgroup(domaincgroup, "/_cgroup.evil/net_cls.evil/__evil= .evil/_cpu.foo.libvirt-lxc", mountsFull, links, placement, NULL, NULL, 0); + return validateCgroup(domaincgroup, mountsFull, links, placement, NULL= , NULL, 0); } =20 static int testCgroupNewForSelfAllInOne(const void *args G_GNUC_UNUSED) @@ -514,7 +505,7 @@ static int testCgroupNewForSelfAllInOne(const void *arg= s G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mountsAllInOne, linksAllInOne, place= ment, NULL, NULL, 0); + return validateCgroup(cgroup, mountsAllInOne, linksAllInOne, placement= , NULL, NULL, 0); } =20 =20 @@ -547,7 +538,7 @@ static int testCgroupNewForSelfUnified(const void *args= G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", empty, empty, empty, + return validateCgroup(cgroup, empty, empty, empty, "/not/really/sys/fs/cgroup", "/", controllers); } =20 @@ -580,7 +571,7 @@ static int testCgroupNewForSelfHybrid(const void *args = G_GNUC_UNUSED) return -1; } =20 - return validateCgroup(cgroup, "", mounts, empty, placement, + return validateCgroup(cgroup, mounts, empty, placement, "/not/really/sys/fs/cgroup/unified", "/", contro= llers); } =20 --=20 2.26.2