From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118366544696.250780823347; Fri, 24 Aug 2018 06:46:06 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3CA533091D6E; Fri, 24 Aug 2018 13:46:04 +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 E1B56546E0; Fri, 24 Aug 2018 13:46:03 +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 4DE2B181A12E; Fri, 24 Aug 2018 13:46:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk0XU024331 for ; Fri, 24 Aug 2018 09:46:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 905462027047; Fri, 24 Aug 2018 13:46:00 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FAF22026D6D for ; Fri, 24 Aug 2018 13:46:00 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:51 +0200 Message-Id: <66a13807f26d93fdd5f524e51be0e83929f9ec32.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] vircgroup: Duplicate string before modifying 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 24 Aug 2018 13:46:04 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The 'mntDir' is part of 'struct mntent' as a result of getmntent_r therefor we should not mangle with it. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index df38bb77e0..45b854e864 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -350,18 +350,22 @@ virCgroupCopyMounts(virCgroupPtr group, =20 =20 static int -virCgroupResolveMountLink(char *mntDir, +virCgroupResolveMountLink(const char *mntDir, const char *typeStr, virCgroupControllerPtr controller) { VIR_AUTOFREE(char *) linkSrc =3D NULL; + VIR_AUTOFREE(char *) tmp =3D NULL; char *dirName; struct stat sb; =20 - dirName =3D strrchr(mntDir, '/'); + if (VIR_STRDUP(tmp, mntDir) < 0) + return -1; + + dirName =3D strrchr(tmp, '/'); if (!dirName) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing '/' separator in cgroup mount '%s'"), mn= tDir); + _("Missing '/' separator in cgroup mount '%s'"), tm= p); return -1; } =20 @@ -369,14 +373,14 @@ virCgroupResolveMountLink(char *mntDir, return 0; =20 *dirName =3D '\0'; - if (virAsprintf(&linkSrc, "%s/%s", mntDir, typeStr) < 0) + if (virAsprintf(&linkSrc, "%s/%s", tmp, typeStr) < 0) return -1; *dirName =3D '/'; =20 if (lstat(linkSrc, &sb) < 0) { if (errno =3D=3D ENOENT) { VIR_WARN("Controller %s co-mounted at %s is missing symlink at= %s", - typeStr, mntDir, linkSrc); + typeStr, tmp, linkSrc); } else { virReportSystemError(errno, _("Cannot stat %s"), linkSrc); return -1; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118367682582.7682495056973; Fri, 24 Aug 2018 06:46:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73BAA3082E72; Fri, 24 Aug 2018 13:46:05 +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 336DD308BDA0; Fri, 24 Aug 2018 13:46:05 +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 CD6704A460; Fri, 24 Aug 2018 13:46:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk1ts024339 for ; Fri, 24 Aug 2018 09:46:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DC392027047; Fri, 24 Aug 2018 13:46:01 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id D15152026D6D for ; Fri, 24 Aug 2018 13:46:00 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:52 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] vircgroup: Extract controller detection into function 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 24 Aug 2018 13:46:06 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 48 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 45b854e864..6f27c50cbd 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -631,24 +631,11 @@ virCgroupDetectPlacement(virCgroupPtr group, =20 =20 static int -virCgroupDetect(virCgroupPtr group, - pid_t pid, - int controllers, - const char *path, - virCgroupPtr parent) +virCgroupDetectControllers(virCgroupPtr group, + int controllers) { size_t i; size_t j; - VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", - group, controllers, path, parent); - - if (parent) { - if (virCgroupCopyMounts(group, parent) < 0) - return -1; - } else { - if (virCgroupDetectMounts(group) < 0) - return -1; - } =20 if (controllers >=3D 0) { VIR_DEBUG("Filtering controllers %d", controllers); @@ -703,8 +690,37 @@ virCgroupDetect(virCgroupPtr group, } } =20 + return controllers; +} + + +static int +virCgroupDetect(virCgroupPtr group, + pid_t pid, + int controllers, + const char *path, + virCgroupPtr parent) +{ + size_t i; + int rc; + + VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", + group, controllers, path, parent); + + if (parent) { + if (virCgroupCopyMounts(group, parent) < 0) + return -1; + } else { + if (virCgroupDetectMounts(group) < 0) + return -1; + } + + rc =3D virCgroupDetectControllers(group, controllers); + if (rc < 0) + return -1; + /* Check that at least 1 controller is available */ - if (!controllers) { + if (rc =3D=3D 0) { virReportSystemError(ENXIO, "%s", _("At least one cgroup controller is required= ")); return -1; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118375779343.5315751184288; Fri, 24 Aug 2018 06:46:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C1D8308421B; Fri, 24 Aug 2018 13:46:13 +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 4FBC2A7F53; Fri, 24 Aug 2018 13:46: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 E1D394A46C; Fri, 24 Aug 2018 13:46:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk2l4024344 for ; Fri, 24 Aug 2018 09:46:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE0862026E03; Fri, 24 Aug 2018 13:46:01 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DCAE2026D6D for ; Fri, 24 Aug 2018 13:46:01 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:53 +0200 Message-Id: <9eb5b962a6a7b22f6e6dd4111184d5bda6d09408.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] vircgroup: Extract placement validation into function 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 24 Aug 2018 13:46:14 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 52 +++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6f27c50cbd..2bc4febf23 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -630,6 +630,36 @@ virCgroupDetectPlacement(virCgroupPtr group, } =20 =20 +static int +virCgroupValidatePlacement(virCgroupPtr group, + pid_t pid) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + if (!group->controllers[i].mountPoint) + continue; + + if (!group->controllers[i].placement) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find placement for controller %s a= t %s"), + virCgroupControllerTypeToString(i), + group->controllers[i].placement); + return -1; + } + + VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld", + i, + virCgroupControllerTypeToString(i), + group->controllers[i].mountPoint, + group->controllers[i].placement, + (long long) pid); + } + + return 0; +} + + static int virCgroupDetectControllers(virCgroupPtr group, int controllers) @@ -701,7 +731,6 @@ virCgroupDetect(virCgroupPtr group, const char *path, virCgroupPtr parent) { - size_t i; int rc; =20 VIR_DEBUG("group=3D%p controllers=3D%d path=3D%s parent=3D%p", @@ -738,25 +767,8 @@ virCgroupDetect(virCgroupPtr group, return -1; =20 /* Check that for every mounted controller, we found our placement */ - for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - if (!group->controllers[i].mountPoint) - continue; - - if (!group->controllers[i].placement) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find placement for controller %s a= t %s"), - virCgroupControllerTypeToString(i), - group->controllers[i].placement); - return -1; - } - - VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld", - i, - virCgroupControllerTypeToString(i), - group->controllers[i].mountPoint, - group->controllers[i].placement, - (long long) pid); - } + if (virCgroupValidatePlacement(group, pid) < 0) + return -1; =20 return 0; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118376287646.5621588567627; Fri, 24 Aug 2018 06:46:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE98285362; Fri, 24 Aug 2018 13:46:13 +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 5E2CE308BDA0; Fri, 24 Aug 2018 13:46: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 E36414A46D; Fri, 24 Aug 2018 13:46:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk2HE024351 for ; Fri, 24 Aug 2018 09:46:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A9EF2026E03; Fri, 24 Aug 2018 13:46:02 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A4D42026D6D for ; Fri, 24 Aug 2018 13:46:02 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:54 +0200 Message-Id: <26bd24c0fc7aaab721ebcbe5b563051c21e2e7d8.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] vircgroup: Split virCgroupPathOfController into two functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 24 Aug 2018 13:46:14 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The case where we need path of any controller is only for internal use so move it out to a different function. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 54 ++++++++++++++++++++++++++------------------ src/util/vircgroup.h | 2 +- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 2bc4febf23..8646a4a479 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1772,28 +1772,13 @@ virCgroupHasController(virCgroupPtr cgroup, int con= troller) =20 int virCgroupPathOfController(virCgroupPtr group, - int controller, + unsigned int controller, const char *key, char **path) { - if (controller =3D=3D -1) { - size_t i; - for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - /* Reject any controller with a placement - * of '/' to avoid doing bad stuff to the root - * cgroup - */ - if (group->controllers[i].mountPoint && - group->controllers[i].placement && - STRNEQ(group->controllers[i].placement, "/")) { - controller =3D i; - break; - } - } - } - if (controller =3D=3D -1) { - virReportSystemError(ENOSYS, "%s", - _("No controllers are mounted")); + if (controller >=3D VIR_CGROUP_CONTROLLER_LAST) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid controller id '%d'"), controller); return -1; } =20 @@ -3505,6 +3490,31 @@ virCgroupRemove(virCgroupPtr group) } =20 =20 +static int +virCgroupPathOfAnyController(virCgroupPtr group, + const char *name, + char **keypath) +{ + size_t i; + + for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + /* Reject any controller with a placement + * of '/' to avoid doing bad stuff to the root + * cgroup + */ + if (group->controllers[i].mountPoint && + group->controllers[i].placement && + STRNEQ(group->controllers[i].placement, "/")) { + return virCgroupPathOfController(group, i, name, keypath); + } + } + + virReportSystemError(ENOSYS, "%s", + _("No controllers are mounted")); + return -1; +} + + /* * Returns 1 if some PIDs are killed, 0 if none are killed, or -1 on error */ @@ -3519,7 +3529,7 @@ virCgroupKillInternal(virCgroupPtr group, int signum,= virHashTablePtr pids) VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", group, group->path, signum, pids); =20 - if (virCgroupPathOfController(group, -1, "tasks", &keypath) < 0) + if (virCgroupPathOfAnyController(group, "tasks", &keypath) < 0) return -1; =20 /* PIDs may be forking as we kill them, so loop @@ -3622,7 +3632,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, VIR_DEBUG("group=3D%p path=3D%s signum=3D%d pids=3D%p", group, group->path, signum, pids); =20 - if (virCgroupPathOfController(group, -1, "", &keypath) < 0) + if (virCgroupPathOfAnyController(group, "", &keypath) < 0) return -1; =20 if ((rc =3D virCgroupKillInternal(group, signum, pids)) < 0) @@ -4180,7 +4190,7 @@ virCgroupHasController(virCgroupPtr cgroup ATTRIBUTE_= UNUSED, =20 int virCgroupPathOfController(virCgroupPtr group ATTRIBUTE_UNUSED, - int controller ATTRIBUTE_UNUSED, + unsigned int controller ATTRIBUTE_UNUSED, const char *key ATTRIBUTE_UNUSED, char **path ATTRIBUTE_UNUSED) { diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index c7fdaaede4..ee3b7c7222 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -114,7 +114,7 @@ void virCgroupFree(virCgroupPtr *group); =20 bool virCgroupHasController(virCgroupPtr cgroup, int controller); int virCgroupPathOfController(virCgroupPtr group, - int controller, + unsigned int controller, const char *key, char **path); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118376526313.15138425092243; Fri, 24 Aug 2018 06:46:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E048C8110B; Fri, 24 Aug 2018 13:46: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 7FB9330912F4; Fri, 24 Aug 2018 13:46: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 F3C01181A139; Fri, 24 Aug 2018 13:46:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk3im024358 for ; Fri, 24 Aug 2018 09:46:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36C5B2026E03; Fri, 24 Aug 2018 13:46:03 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA8D12026D6D for ; Fri, 24 Aug 2018 13:46:02 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:55 +0200 Message-Id: <41036d261a6d1fb875a27e851ca6849034410ca1.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] vircgroup: Call virCgroupRemove inside virCgroupMakeGroup 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 24 Aug 2018 13:46:15 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This fixes virCgroupEnableMissingControllers where virCgroupRemove was not called in case virCgroupMakeGroup failed. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 8646a4a479..dde9ed21a2 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1052,7 +1052,7 @@ virCgroupMakeGroup(virCgroupPtr parent, } =20 if (virCgroupPathOfController(group, i, "", &path) < 0) - return -1; + goto error; =20 /* As of Feb 2011, clang can't see that the above function * call did not modify group. */ @@ -1076,7 +1076,7 @@ virCgroupMakeGroup(virCgroupPtr parent, virReportSystemError(errno, _("Failed to create controller %s= for group"), virCgroupControllerTypeToString(i= )); - return -1; + goto error; } } if (group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoin= t !=3D NULL && @@ -1084,7 +1084,7 @@ virCgroupMakeGroup(virCgroupPtr parent, STREQ(group->controllers[i].mountPoint, group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mo= untPoint))) { if (virCgroupCpuSetInherit(parent, group) < 0) - return -1; + goto error; } /* * Note that virCgroupSetMemoryUseHierarchy should always be @@ -1096,13 +1096,17 @@ virCgroupMakeGroup(virCgroupPtr parent, STREQ(group->controllers[i].mountPoint, group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mo= untPoint))) { if (virCgroupSetMemoryUseHierarchy(group) < 0) - return -1; + goto error; } } } =20 VIR_DEBUG("Done making controllers for group"); return 0; + + error: + virCgroupRemove(group); + return -1; } =20 =20 @@ -1316,10 +1320,8 @@ virCgroupNewPartition(const char *path, if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) goto cleanup; =20 - if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < = 0) { - virCgroupRemove(*group); + if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < = 0) goto cleanup; - } } =20 ret =3D 0; @@ -1389,7 +1391,6 @@ virCgroupNewDomainPartition(virCgroupPtr partition, */ if (virCgroupMakeGroup(partition, *group, create, VIR_CGROUP_MEM_HIERACHY) < 0) { - virCgroupRemove(*group); virCgroupFree(group); return -1; } @@ -1446,7 +1447,6 @@ virCgroupNewThread(virCgroupPtr domain, return -1; =20 if (virCgroupMakeGroup(domain, *group, create, VIR_CGROUP_NONE) < 0) { - virCgroupRemove(*group); virCgroupFree(group); return -1; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118380861828.0460267793666; Fri, 24 Aug 2018 06:46:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8095832B69D; Fri, 24 Aug 2018 13:46:18 +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 42E3F907FD; Fri, 24 Aug 2018 13:46:18 +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 AD0FC181A139; Fri, 24 Aug 2018 13:46:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk3HQ024364 for ; Fri, 24 Aug 2018 09:46:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id D77782026E03; Fri, 24 Aug 2018 13:46:03 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76EB02026D6D for ; Fri, 24 Aug 2018 13:46:03 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:56 +0200 Message-Id: <9a6554d1e90490672055fbeb070ac3bb82711b32.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] vircgroup: Simplify if conditions in virCgroupMakeGroup 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 24 Aug 2018 13:46:19 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index dde9ed21a2..02de33f74f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1079,24 +1079,20 @@ virCgroupMakeGroup(virCgroupPtr parent, goto error; } } - if (group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoin= t !=3D NULL && - (i =3D=3D VIR_CGROUP_CONTROLLER_CPUSET || - STREQ(group->controllers[i].mountPoint, - group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mo= untPoint))) { - if (virCgroupCpuSetInherit(parent, group) < 0) - goto error; + if (i =3D=3D VIR_CGROUP_CONTROLLER_CPUSET && + group->controllers[i].mountPoint !=3D NULL && + virCgroupCpuSetInherit(parent, group) < 0) { + goto error; } /* * Note that virCgroupSetMemoryUseHierarchy should always be * called prior to creating subcgroups and attaching tasks. */ if ((flags & VIR_CGROUP_MEM_HIERACHY) && - (group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoi= nt !=3D NULL) && - (i =3D=3D VIR_CGROUP_CONTROLLER_MEMORY || - STREQ(group->controllers[i].mountPoint, - group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mo= untPoint))) { - if (virCgroupSetMemoryUseHierarchy(group) < 0) - goto error; + i =3D=3D VIR_CGROUP_CONTROLLER_MEMORY && + group->controllers[i].mountPoint !=3D NULL && + virCgroupSetMemoryUseHierarchy(group) < 0) { + goto error; } } } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 22:56:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1535118381510545.4784381813157; Fri, 24 Aug 2018 06:46:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2372E356EC; Fri, 24 Aug 2018 13:46:19 +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 CAD7461470; Fri, 24 Aug 2018 13:46:18 +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 800994BB7F; Fri, 24 Aug 2018 13:46:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7ODk4QD024375 for ; Fri, 24 Aug 2018 09:46:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 833FC2026E03; Fri, 24 Aug 2018 13:46:04 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22D412026D6D for ; Fri, 24 Aug 2018 13:46:04 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 24 Aug 2018 15:45:57 +0200 Message-Id: <0c264cd90174a8cd1072f89836052c60f43a7da6.1535118274.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] vircgroup: Remove obsolete sa_assert 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 24 Aug 2018 13:46:20 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 02de33f74f..64507bf8aa 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1054,10 +1054,6 @@ virCgroupMakeGroup(virCgroupPtr parent, if (virCgroupPathOfController(group, i, "", &path) < 0) goto error; =20 - /* As of Feb 2011, clang can't see that the above function - * call did not modify group. */ - sa_assert(group->controllers[i].mountPoint); - VIR_DEBUG("Make controller %s", path); if (!virFileExists(path)) { if (!create || --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list