From nobody Thu May 16 00:50: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 1533822274945513.4742191408399; Thu, 9 Aug 2018 06:44:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB07E3082A42; Thu, 9 Aug 2018 13:44:32 +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 74D831902F; Thu, 9 Aug 2018 13:44:32 +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 232F11841C57; Thu, 9 Aug 2018 13:44:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiG68014976 for ; Thu, 9 Aug 2018 09:44:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 529792314D; Thu, 9 Aug 2018 13:44:16 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5CF02314E for ; Thu, 9 Aug 2018 13:44:15 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:43:56 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/17] docs: List cpuacct in controllers used by QEMU driver 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 09 Aug 2018 13:44:33 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The cpuacct controller is used to get cpu stats. Signed-off-by: Pavel Hrdina --- docs/cgroups.html.in | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in index e33d07a82b..a498590c45 100644 --- a/docs/cgroups.html.in +++ b/docs/cgroups.html.in @@ -23,12 +23,13 @@ =20

The QEMU driver is capable of using the cpuset, - cpu, memory, blkio and - devices controllers. None of them are compulsory. - If any controller is not mounted, the resource management APIs - which use it will cease to operate. It is possible to explicitly - turn off use of a controller, even when mounted, via the - /etc/libvirt/qemu.conf configuration file. + cpu, cpuacct, memory, + blkio and devices controllers. + None of them are compulsory. If any controller is not mounted, + the resource management APIs which use it will cease to operate. + It is possible to explicitly turn off use of a controller, + even when mounted, via the /etc/libvirt/qemu.conf + configuration file.

=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 16 00:50: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 1533822325951452.44942893403504; Thu, 9 Aug 2018 06:45:25 -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 9C33580F9E; Thu, 9 Aug 2018 13:45:22 +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 43737537AA; Thu, 9 Aug 2018 13:45:22 +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 D30F024F61; Thu, 9 Aug 2018 13:45:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiH9W014981 for ; Thu, 9 Aug 2018 09:44:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id F1ED52314D; Thu, 9 Aug 2018 13:44:16 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90A622314E for ; Thu, 9 Aug 2018 13:44:16 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:43:57 +0200 Message-Id: <9c2ba801d486688322ca373a3f74fa831c6a1998.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/17] docs: Update how we create cgroup directory names 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.27]); Thu, 09 Aug 2018 13:45:24 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit changed the way how cgroup directory names are constructed but the documentation was not updated. Signed-off-by: Pavel Hrdina --- docs/cgroups.html.in | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in index a498590c45..081ba2eae1 100644 --- a/docs/cgroups.html.in +++ b/docs/cgroups.html.in @@ -76,11 +76,13 @@

The systemd convention is for the scope name of virtual machines / c= ontainers to be of the general format machine-$NAME.scope. Libvir= t forms the - $NAME part of this by concatenating the driver type wit= h the name - of the guest, and then escaping any systemd reserved characters. + $NAME part of this by concatenating the driver type wit= h the id + and truncated name of the guest, and then escaping any systemd reser= ved + characters. So for a guest demo running under the lxc = driver, - we get a $NAME of lxc-demo which when esca= ped is - lxc\x2ddemo. So the complete scope name is machin= e-lxc\x2ddemo.scope. + we get a $NAME of lxc-12345-demo which whe= n escaped + is lxc\x2d12345\x2ddemo. So the complete scope name is + machine-lxc\x2d12345\x2ddemo.scope. The scope names map directly to the cgroup directory names.

=20 @@ -113,19 +115,19 @@ $ROOT | +- machine.slice | - +- machine-qemu\x2dvm1.scope + +- machine-qemu\x2d1\x2dvm1.scope | | | +- emulator | +- vcpu0 | +- vcpu1 | - +- machine-qemu\x2dvm2.scope + +- machine-qemu\x2d2\x2dvm2.scope | | | +- emulator | +- vcpu0 | +- vcpu1 | - +- machine-qemu\x2dvm3.scope + +- machine-qemu\x2d3\x2dvm3.scope | | | +- emulator | +- vcpu0 @@ -135,15 +137,15 @@ $ROOT | | | +- machine-engineering-testing.slice | | | - | | +- machine-lxc\x2dcontainer1.scope + | | +- machine-lxc\x2d11111\x2dcontainer1.scope | | | +- machine-engineering-production.slice | | - | +- machine-lxc\x2dcontainer2.scope + | +- machine-lxc\x2d22222\x2dcontainer2.scope | +- machine-marketing.slice | - +- machine-lxc\x2dcontainer3.scope + +- machine-lxc\x2d33333\x2dcontainer3.scope =20

Non-systemd cgroups layout

@@ -174,19 +176,19 @@ $ROOT | +- machine | - +- vm1.libvirt-qemu + +- qemu-1-vm1.libvirt-qemu | | | +- emulator | +- vcpu0 | +- vcpu1 | - +- vm2.libvirt-qemu + +- qeme-2-vm2.libvirt-qemu | | | +- emulator | +- vcpu0 | +- vcpu1 | - +- vm3.libvirt-qemu + +- qemu-3-vm3.libvirt-qemu | | | +- emulator | +- vcpu0 @@ -196,15 +198,15 @@ $ROOT | | | +- testing.partition | | | - | | +- container1.libvirt-lxc + | | +- lxc-11111-container1.libvirt-lxc | | | +- production.partition | | - | +- container2.libvirt-lxc + | +- lxc-22222-container2.libvirt-lxc | +- marketing.partition | - +- container3.libvirt-lxc + +- lxc-33333-container3.libvirt-lxc =20

Using custom partitions

--=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 153382226863126.33812004286449; Thu, 9 Aug 2018 06:44:28 -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 40B2812C06; Thu, 9 Aug 2018 13:44:26 +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 6DB6B5FC0A; Thu, 9 Aug 2018 13:44:25 +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 2A49B1841C49; Thu, 9 Aug 2018 13:44:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiHBn014994 for ; Thu, 9 Aug 2018 09:44:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CEF42314D; Thu, 9 Aug 2018 13:44:17 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C18523151 for ; Thu, 9 Aug 2018 13:44:17 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:43:58 +0200 Message-Id: <632bcb013d3b3ff2eecbee1dcb6a16f598f7c57e.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/17] vircgroup: Rename structs to start with underscore 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.26]); Thu, 09 Aug 2018 13:44:27 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 2 +- src/util/vircgroup.h | 4 ++-- src/util/vircgrouppriv.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6bf4e88da1..7602641713 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -385,7 +385,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, const char *typestr =3D virCgroupControllerTypeToString(i); int typelen =3D strlen(typestr); char *tmp =3D entry.mnt_opts; - struct virCgroupController *controller =3D &group->controllers= [i]; + struct _virCgroupController *controller =3D &group->controller= s[i]; while (tmp) { char *next =3D strchr(tmp, ','); int len; diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index d833927678..cfa69b67cb 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -28,8 +28,8 @@ # include "virutil.h" # include "virbitmap.h" =20 -struct virCgroup; -typedef struct virCgroup *virCgroupPtr; +struct _virCgroup; +typedef struct _virCgroup *virCgroupPtr; =20 enum { VIR_CGROUP_CONTROLLER_CPU, diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 722863e5b6..71788639d6 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -31,7 +31,7 @@ =20 # include "vircgroup.h" =20 -struct virCgroupController { +struct _virCgroupController { int type; char *mountPoint; /* If mountPoint holds several controllers co-mounted, @@ -42,10 +42,10 @@ struct virCgroupController { char *placement; }; =20 -struct virCgroup { +struct _virCgroup { char *path; =20 - struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; + struct _virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; }; =20 int virCgroupDetectMountsFromFile(virCgroupPtr group, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822278907915.0207880684528; Thu, 9 Aug 2018 06:44:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E46078110E; Thu, 9 Aug 2018 13:44:36 +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 A79F8675F7; Thu, 9 Aug 2018 13:44:36 +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 57C763FCC2; Thu, 9 Aug 2018 13:44:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiIeI015001 for ; Thu, 9 Aug 2018 09:44:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 475DF2314D; Thu, 9 Aug 2018 13:44:18 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAE512314E for ; Thu, 9 Aug 2018 13:44:17 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:43:59 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/17] vircgroup: Introduce standard set of typedefs and use them 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 09 Aug 2018 13:44:37 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 2 +- src/util/vircgroup.h | 3 ++- src/util/vircgrouppriv.h | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 7602641713..5144b33d43 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -385,7 +385,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, const char *typestr =3D virCgroupControllerTypeToString(i); int typelen =3D strlen(typestr); char *tmp =3D entry.mnt_opts; - struct _virCgroupController *controller =3D &group->controller= s[i]; + virCgroupControllerPtr controller =3D &group->controllers[i]; while (tmp) { char *next =3D strchr(tmp, ','); int len; diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index cfa69b67cb..af93316197 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -29,7 +29,8 @@ # include "virbitmap.h" =20 struct _virCgroup; -typedef struct _virCgroup *virCgroupPtr; +typedef struct _virCgroup virCgroup; +typedef virCgroup *virCgroupPtr; =20 enum { VIR_CGROUP_CONTROLLER_CPU, diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 71788639d6..1b47d3b858 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -41,11 +41,13 @@ struct _virCgroupController { char *linkPoint; char *placement; }; +typedef struct _virCgroupController virCgroupController; +typedef virCgroupController *virCgroupControllerPtr; =20 struct _virCgroup { char *path; =20 - struct _virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; + virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; }; =20 int virCgroupDetectMountsFromFile(virCgroupPtr group, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822329719590.6085077997143; Thu, 9 Aug 2018 06:45:29 -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 8CD0A931D5; Thu, 9 Aug 2018 13:45:27 +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 550AF2D099; Thu, 9 Aug 2018 13:45:27 +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 EC82F1841C5A; Thu, 9 Aug 2018 13:45:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiJ74015007 for ; Thu, 9 Aug 2018 09:44:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6E4C2314D; Thu, 9 Aug 2018 13:44:18 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85F1A2314E for ; Thu, 9 Aug 2018 13:44:18 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:00 +0200 Message-Id: <484ae72ac1cb7ae2af64f471e8c1dde945e7565e.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/17] vircgroup: Extract file link resolving into separate 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.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.26]); Thu, 09 Aug 2018 13:45:28 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 85 +++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 5144b33d43..fd58ba154f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -356,6 +356,51 @@ virCgroupCopyMounts(virCgroupPtr group, } =20 =20 +static int +virCgroupResolveMountLink(const char *mntDir, + const char *typeStr, + virCgroupControllerPtr controller) +{ + VIR_AUTOFREE(char *) linkSrc =3D NULL; + char *dirName; + struct stat sb; + + dirName =3D strrchr(mntDir, '/'); + if (!dirName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing '/' separator in cgroup mount '%s'"), mn= tDir); + return -1; + } + + if (!strchr(dirName + 1, ',')) + return 0; + + *dirName =3D '\0'; + if (virAsprintf(&linkSrc, "%s/%s", mntDir, typeStr) < 0) + return -1; + *dirName =3D '/'; + + 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); + } else { + virReportSystemError(errno, _("Cannot stat %s"), linkSrc); + return -1; + } + } else { + if (!S_ISLNK(sb.st_mode)) { + VIR_WARN("Expecting a symlink at %s for controller %s", + linkSrc, typeStr); + } else { + VIR_STEAL_PTR(controller->linkPoint, linkSrc); + } + } + + return 0; +} + + /* * Process /proc/mounts figuring out what controllers are * mounted and where @@ -397,8 +442,6 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, } =20 if (typelen =3D=3D len && STREQLEN(typestr, tmp, len)) { - struct stat sb; - char *tmp2; =20 /* Note that the lines in /proc/mounts have the same * order than the mount operations, and that there may @@ -412,44 +455,12 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) = < 0) goto cleanup; =20 - tmp2 =3D strrchr(entry.mnt_dir, '/'); - if (!tmp2) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing '/' separator in cgroup = mount '%s'"), - entry.mnt_dir); - goto cleanup; - } - /* If it is a co-mount it has a filename like "cpu,cpu= acct" * and we must identify the symlink path */ - if (checkLinks && strchr(tmp2 + 1, ',')) { - VIR_AUTOFREE(char *) linksrc =3D NULL; - - *tmp2 =3D '\0'; - if (virAsprintf(&linksrc, "%s/%s", - entry.mnt_dir, typestr) < 0) + if (checkLinks && + virCgroupResolveMountLink(entry.mnt_dir, typestr, + controller) < 0) { goto cleanup; - *tmp2 =3D '/'; - - if (lstat(linksrc, &sb) < 0) { - if (errno =3D=3D ENOENT) { - VIR_WARN("Controller %s co-mounted at %s i= s missing symlink at %s", - typestr, entry.mnt_dir, linksrc); - } else { - virReportSystemError(errno, - _("Cannot stat %s"), - linksrc); - goto cleanup; - } - } else { - if (!S_ISLNK(sb.st_mode)) { - VIR_WARN("Expecting a symlink at %s for co= ntroller %s", - linksrc, typestr); - } else { - controller->linkPoint =3D linksrc; - linksrc =3D NULL; - } - } } } tmp =3D next; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822274848980.2716788201787; Thu, 9 Aug 2018 06:44:34 -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 9112D80F90; Thu, 9 Aug 2018 13:44:32 +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 5A9C317D5D; Thu, 9 Aug 2018 13:44:32 +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 0A0BB1841C5A; Thu, 9 Aug 2018 13:44:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiJgL015018 for ; Thu, 9 Aug 2018 09:44:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 912932314D; Thu, 9 Aug 2018 13:44:19 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 309E72314E for ; Thu, 9 Aug 2018 13:44:19 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:01 +0200 Message-Id: <79e9e5ddd4f89c296b68350c3319d673845cdbb5.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/17] vircgroup: Remove unused function virCgroupKill() 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.27]); Thu, 09 Aug 2018 13:44:33 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/vircgroup.c | 37 ------------------------------------- src/util/vircgroup.h | 1 - 3 files changed, 39 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 32ed5a09f9..8f80ee2250 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1539,7 +1539,6 @@ virCgroupGetMemSwapUsage; virCgroupGetPercpuStats; virCgroupHasController; virCgroupHasEmptyTasks; -virCgroupKill; virCgroupKillPainfully; virCgroupKillRecursive; virCgroupNewDetect; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index fd58ba154f..d9f6c5b06f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3510,33 +3510,6 @@ virCgroupPidCopy(const void *name) } =20 =20 -/* - * Returns 1 if some PIDs are killed, 0 if none are killed, or -1 on error - */ -int -virCgroupKill(virCgroupPtr group, int signum) -{ - VIR_DEBUG("group=3D%p path=3D%s signum=3D%d", group, group->path, sign= um); - int ret; - /* The 'tasks' file in cgroups can contain duplicated - * pids, so we use a hash to track which we've already - * killed. - */ - virHashTablePtr pids =3D virHashCreateFull(100, - NULL, - virCgroupPidCode, - virCgroupPidEqual, - virCgroupPidCopy, - NULL); - - ret =3D virCgroupKillInternal(group, signum, pids); - - virHashFree(pids); - - return ret; -} - - static int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, @@ -4585,16 +4558,6 @@ virCgroupRemove(virCgroupPtr group ATTRIBUTE_UNUSED) } =20 =20 -int -virCgroupKill(virCgroupPtr group ATTRIBUTE_UNUSED, - int signum ATTRIBUTE_UNUSED) -{ - virReportSystemError(ENOSYS, "%s", - _("Control groups not supported on this platform"= )); - return -1; -} - - int virCgroupKillRecursive(virCgroupPtr group ATTRIBUTE_UNUSED, int signum ATTRIBUTE_UNUSED) diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index af93316197..a23a491d95 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -280,7 +280,6 @@ int virCgroupGetCpusetCpus(virCgroupPtr group, char **c= pus); int virCgroupRemoveRecursively(char *grppath); int virCgroupRemove(virCgroupPtr group); =20 -int virCgroupKill(virCgroupPtr group, int signum); int virCgroupKillRecursive(virCgroupPtr group, int signum); int virCgroupKillPainfully(virCgroupPtr group); =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 16 00:50: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 1533822279050423.35290552304946; Thu, 9 Aug 2018 06:44:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F01703082A54; Thu, 9 Aug 2018 13:44:36 +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 AE919675F8; Thu, 9 Aug 2018 13:44:36 +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 5D0461841C67; Thu, 9 Aug 2018 13:44:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiKRl015026 for ; Thu, 9 Aug 2018 09:44:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C3802314D; Thu, 9 Aug 2018 13:44:20 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF88523151 for ; Thu, 9 Aug 2018 13:44:19 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:02 +0200 Message-Id: <4ed8bef3af3856855c7829918c6ced4e7ad3ee2d.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/17] vircgroup: Unexport unused function virCgroupAddTaskController() 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 09 Aug 2018 13:44:37 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/vircgroup.c | 69 +++++++++++++++++----------------------- src/util/vircgroup.h | 4 --- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8f80ee2250..95d7c9f834 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1496,7 +1496,6 @@ virBufferVasprintf; # util/vircgroup.h virCgroupAddMachineTask; virCgroupAddTask; -virCgroupAddTaskController; virCgroupAllowAllDevices; virCgroupAllowDevice; virCgroupAllowDevicePath; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index d9f6c5b06f..6d937626e6 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1136,6 +1136,35 @@ virCgroupNew(pid_t pid, } =20 =20 +/** + * virCgroupAddTaskController: + * + * @group: The cgroup to add a task to + * @pid: The pid of the task to add + * @controller: The cgroup controller to be operated on + * + * Returns: 0 on success or -1 on error + */ +static int +virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller) +{ + if (controller < 0 || controller >=3D VIR_CGROUP_CONTROLLER_LAST) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Controller %d out of range"), controller); + return -1; + } + + if (!group->controllers[controller].mountPoint) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Controller '%s' not mounted"), + virCgroupControllerTypeToString(controller)); + return -1; + } + + return virCgroupSetValueI64(group, controller, "tasks", pid); +} + + static int virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd) { @@ -1197,35 +1226,6 @@ virCgroupAddMachineTask(virCgroupPtr group, pid_t pi= d) } =20 =20 -/** - * virCgroupAddTaskController: - * - * @group: The cgroup to add a task to - * @pid: The pid of the task to add - * @controller: The cgroup controller to be operated on - * - * Returns: 0 on success or -1 on error - */ -int -virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller) -{ - if (controller < 0 || controller >=3D VIR_CGROUP_CONTROLLER_LAST) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Controller %d out of range"), controller); - return -1; - } - - if (!group->controllers[controller].mountPoint) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Controller '%s' not mounted"), - virCgroupControllerTypeToString(controller)); - return -1; - } - - return virCgroupSetValueI64(group, controller, "tasks", pid); -} - - static int virCgroupSetPartitionSuffix(const char *path, char **res) { @@ -4115,17 +4115,6 @@ virCgroupAddMachineTask(virCgroupPtr group ATTRIBUTE= _UNUSED, } =20 =20 -int -virCgroupAddTaskController(virCgroupPtr group ATTRIBUTE_UNUSED, - pid_t pid ATTRIBUTE_UNUSED, - int controller ATTRIBUTE_UNUSED) -{ - virReportSystemError(ENXIO, "%s", - _("Control groups not supported on this platform"= )); - return -1; -} - - int virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED, long long *bytes_read ATTRIBUTE_UNUSED, diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index a23a491d95..74c7dbcccc 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -134,10 +134,6 @@ int virCgroupPathOfController(virCgroupPtr group, int virCgroupAddTask(virCgroupPtr group, pid_t pid); int virCgroupAddMachineTask(virCgroupPtr group, pid_t pid); =20 -int virCgroupAddTaskController(virCgroupPtr group, - pid_t pid, - int controller); - int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight); int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight); =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 16 00:50: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 1533822285202166.38558810700988; Thu, 9 Aug 2018 06:44:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4F60C87624; Thu, 9 Aug 2018 13:44:43 +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 1D442587F2; Thu, 9 Aug 2018 13:44:43 +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 C4C253F7FF; Thu, 9 Aug 2018 13:44:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiLTq015031 for ; Thu, 9 Aug 2018 09:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id DBF692314D; Thu, 9 Aug 2018 13:44:20 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A9702314E for ; Thu, 9 Aug 2018 13:44:20 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:03 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/17] vircgroup: Unexport unused function virCgroupRemoveRecursively 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 09 Aug 2018 13:44:43 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/vircgroup.c | 11 +---------- src/util/vircgroup.h | 1 - 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 95d7c9f834..59d9bc380e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1550,7 +1550,6 @@ virCgroupNewSelf; virCgroupNewThread; virCgroupPathOfController; virCgroupRemove; -virCgroupRemoveRecursively; virCgroupSetBlkioDeviceReadBps; virCgroupSetBlkioDeviceReadIops; virCgroupSetBlkioDeviceWeight; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6d937626e6..280d781f41 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3312,7 +3312,7 @@ virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, ch= ar **usage) } =20 =20 -int +static int virCgroupRemoveRecursively(char *grppath) { DIR *grpdir; @@ -4529,15 +4529,6 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group ATTRIBUTE= _UNUSED, } =20 =20 -int -virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED) -{ - virReportSystemError(ENXIO, "%s", - _("Control groups not supported on this platform"= )); - return -1; -} - - int virCgroupRemove(virCgroupPtr group ATTRIBUTE_UNUSED) { diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 74c7dbcccc..138bb3c076 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -273,7 +273,6 @@ int virCgroupGetCpusetMemoryMigrate(virCgroupPtr group,= bool *migrate); int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus); int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus); =20 -int virCgroupRemoveRecursively(char *grppath); int virCgroupRemove(virCgroupPtr group); =20 int virCgroupKillRecursive(virCgroupPtr group, int signum); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822334562888.1709355127701; Thu, 9 Aug 2018 06:45:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56E5F307D867; Thu, 9 Aug 2018 13:45:32 +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 15E2920155E0; Thu, 9 Aug 2018 13:45:32 +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 BB4791841C5C; Thu, 9 Aug 2018 13:45:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiLN1015044 for ; Thu, 9 Aug 2018 09:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 862DF2314D; Thu, 9 Aug 2018 13:44:21 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 259482314E for ; Thu, 9 Aug 2018 13:44:21 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:04 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/17] vircgroup: Move function used in tests into vircgrouppriv.h 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 09 Aug 2018 13:45:33 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.h | 13 ------------- src/util/vircgrouppriv.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 138bb3c076..48be077aba 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -64,22 +64,9 @@ typedef enum { =20 bool virCgroupAvailable(void); =20 -int virCgroupNewPartition(const char *path, - bool create, - int controllers, - virCgroupPtr *group) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); - int virCgroupNewSelf(virCgroupPtr *group) ATTRIBUTE_NONNULL(1); =20 -int virCgroupNewDomainPartition(virCgroupPtr partition, - const char *driver, - const char *name, - bool create, - virCgroupPtr *group) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); - int virCgroupNewThread(virCgroupPtr domain, virCgroupThreadName nameval, int id, diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 1b47d3b858..a0034f3889 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -54,4 +54,17 @@ int virCgroupDetectMountsFromFile(virCgroupPtr group, const char *path, bool checkLinks); =20 +int virCgroupNewPartition(const char *path, + bool create, + int controllers, + virCgroupPtr *group) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); + +int virCgroupNewDomainPartition(virCgroupPtr partition, + const char *driver, + const char *name, + bool create, + virCgroupPtr *group) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); + #endif /* __VIR_CGROUP_PRIV_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822282682163.4289890435681; Thu, 9 Aug 2018 06:44:42 -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 C9F9A201FB; Thu, 9 Aug 2018 13:44:40 +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 96B835C8B9; Thu, 9 Aug 2018 13:44:40 +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 579E03FA54; Thu, 9 Aug 2018 13:44:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiMfd015060 for ; Thu, 9 Aug 2018 09:44:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82DC92314D; Thu, 9 Aug 2018 13:44:22 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C490D2314E for ; Thu, 9 Aug 2018 13:44:21 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:05 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/17] vircgroup: Remove pointless bool parameter 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.29]); Thu, 09 Aug 2018 13:44:41 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 280d781f41..6ffa1e9c58 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -251,7 +251,6 @@ static bool virCgroupValidateMachineGroup(virCgroupPtr group, const char *name, const char *drivername, - bool stripEmulatorSuffix, const char *machinename) { size_t i; @@ -303,10 +302,9 @@ virCgroupValidateMachineGroup(virCgroupPtr group, if (!tmp) return false; =20 - if (stripEmulatorSuffix && - (i =3D=3D VIR_CGROUP_CONTROLLER_CPU || - i =3D=3D VIR_CGROUP_CONTROLLER_CPUACCT || - i =3D=3D VIR_CGROUP_CONTROLLER_CPUSET)) { + if (i =3D=3D VIR_CGROUP_CONTROLLER_CPU || + i =3D=3D VIR_CGROUP_CONTROLLER_CPUACCT || + i =3D=3D VIR_CGROUP_CONTROLLER_CPUSET) { if (STREQ(tmp, "/emulator")) *tmp =3D '\0'; tmp =3D strrchr(group->controllers[i].placement, '/'); @@ -1486,8 +1484,7 @@ virCgroupNewDetectMachine(const char *name, return -1; } =20 - if (!virCgroupValidateMachineGroup(*group, name, drivername, - true, machinename)) { + if (!virCgroupValidateMachineGroup(*group, name, drivername, machinena= me)) { VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'", name, drivername); virCgroupFree(group); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822289625882.9476955837537; Thu, 9 Aug 2018 06:44:49 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 662E2C015C16; Thu, 9 Aug 2018 13:44:47 +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 2D276587F7; Thu, 9 Aug 2018 13:44:47 +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 D3B631841C70; Thu, 9 Aug 2018 13:44:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiNb3015067 for ; Thu, 9 Aug 2018 09:44:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DF662314D; Thu, 9 Aug 2018 13:44:23 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C14C623151 for ; Thu, 9 Aug 2018 13:44:22 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:06 +0200 Message-Id: <54d6d4343be7e266f6e0827c8b9bd03dfb4d16e7.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/17] vircgroup: Extract mount options matching 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 09 Aug 2018 13:44:48 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 80 ++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 6ffa1e9c58..52be5e5fb8 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -399,6 +399,33 @@ virCgroupResolveMountLink(const char *mntDir, } =20 =20 +static bool +virCgroupMountOptsMatchController(const char *mntOpts, + const char *typeStr) +{ + const char *tmp =3D mntOpts; + int typeLen =3D strlen(typeStr); + + while (tmp) { + const char *next =3D strchr(tmp, ','); + int len; + if (next) { + len =3D next - tmp; + next++; + } else { + len =3D strlen(tmp); + } + + if (typeLen =3D=3D len && STREQLEN(typeStr, tmp, len)) + return true; + + tmp =3D next; + } + + return false; +} + + /* * Process /proc/mounts figuring out what controllers are * mounted and where @@ -426,42 +453,29 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, =20 for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { const char *typestr =3D virCgroupControllerTypeToString(i); - int typelen =3D strlen(typestr); - char *tmp =3D entry.mnt_opts; - virCgroupControllerPtr controller =3D &group->controllers[i]; - while (tmp) { - char *next =3D strchr(tmp, ','); - int len; - if (next) { - len =3D next-tmp; - next++; - } else { - len =3D strlen(tmp); - } =20 - if (typelen =3D=3D len && STREQLEN(typestr, tmp, len)) { - - /* Note that the lines in /proc/mounts have the same - * order than the mount operations, and that there may - * be duplicates due to bind mounts. This means - * that the same mount point may be processed more than - * once. We need to save the results of the last one, - * and we need to be careful to release the memory used - * by previous processing. */ - VIR_FREE(controller->mountPoint); - VIR_FREE(controller->linkPoint); - if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) = < 0) - goto cleanup; + if (virCgroupMountOptsMatchController(entry.mnt_opts, typestr)= ) { + /* Note that the lines in /proc/mounts have the same + * order than the mount operations, and that there may + * be duplicates due to bind mounts. This means + * that the same mount point may be processed more than + * once. We need to save the results of the last one, + * and we need to be careful to release the memory used + * by previous processing. */ + virCgroupControllerPtr controller =3D &group->controllers[= i]; + + VIR_FREE(controller->mountPoint); + VIR_FREE(controller->linkPoint); + if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) < 0) + goto cleanup; =20 - /* If it is a co-mount it has a filename like "cpu,cpu= acct" - * and we must identify the symlink path */ - if (checkLinks && - virCgroupResolveMountLink(entry.mnt_dir, typestr, - controller) < 0) { - goto cleanup; - } + /* If it is a co-mount it has a filename like "cpu,cpuacct" + * and we must identify the symlink path */ + if (checkLinks && + virCgroupResolveMountLink(entry.mnt_dir, typestr, + controller) < 0) { + goto cleanup; } - tmp =3D next; } } } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822339155536.8228288692468; Thu, 9 Aug 2018 06:45:39 -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 02865C0587F7; Thu, 9 Aug 2018 13:45:37 +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 B84FD308BDAC; Thu, 9 Aug 2018 13:45:36 +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 5F15B24F61; Thu, 9 Aug 2018 13:45:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiNk7015072 for ; Thu, 9 Aug 2018 09:44:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD1E52314D; Thu, 9 Aug 2018 13:44:23 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C10C2314E for ; Thu, 9 Aug 2018 13:44:23 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:07 +0200 Message-Id: <0c7c84dbc923ee596f764103e3474e34bea75900.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/17] vircgroup: Use virCgroupMountOptsMatchController in virCgroupDetectPlacement 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.32]); Thu, 09 Aug 2018 13:45:37 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 52be5e5fb8..45fe2595d1 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -598,42 +598,27 @@ virCgroupDetectPlacement(virCgroupPtr group, =20 for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { const char *typestr =3D virCgroupControllerTypeToString(i); - int typelen =3D strlen(typestr); - char *tmp =3D controllers; - - while (tmp) { - char *next =3D strchr(tmp, ','); - int len; - if (next) { - len =3D next - tmp; - next++; - } else { - len =3D strlen(tmp); - } =20 + if (virCgroupMountOptsMatchController(controllers, typestr) && + group->controllers[i].mountPoint !=3D NULL && + group->controllers[i].placement =3D=3D NULL) { /* * selfpath =3D=3D "/" + path=3D"" -> "/" * selfpath =3D=3D "/libvirt.service" + path =3D=3D "" -> = "/libvirt.service" * selfpath =3D=3D "/libvirt.service" + path =3D=3D "foo" = -> "/libvirt.service/foo" */ - if (typelen =3D=3D len && STREQLEN(typestr, tmp, len) && - group->controllers[i].mountPoint !=3D NULL && - group->controllers[i].placement =3D=3D NULL) { - if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) { - if (VIR_STRDUP(group->controllers[i].placement, - selfpath) < 0) - goto cleanup; - } else { - if (virAsprintf(&group->controllers[i].placement, - "%s%s%s", selfpath, - (STREQ(selfpath, "/") || - STREQ(path, "") ? "" : "/"), - path) < 0) - goto cleanup; - } + if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) { + if (VIR_STRDUP(group->controllers[i].placement, + selfpath) < 0) + goto cleanup; + } else { + if (virAsprintf(&group->controllers[i].placement, + "%s%s%s", selfpath, + (STREQ(selfpath, "/") || + STREQ(path, "") ? "" : "/"), + path) < 0) + goto cleanup; } - - tmp =3D next; } } } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822343636534.7000803201104; Thu, 9 Aug 2018 06:45:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38CE6317C3F7; Thu, 9 Aug 2018 13:45: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 03C1C201562E; Thu, 9 Aug 2018 13:45: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 9B8B51841C66; Thu, 9 Aug 2018 13:45:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiOao015077 for ; Thu, 9 Aug 2018 09:44:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 77C392314D; Thu, 9 Aug 2018 13:44:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16C302314E for ; Thu, 9 Aug 2018 13:44:23 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:08 +0200 Message-Id: <49ebdc92bdb494a68b912581c1e2a3bcdbab6631.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/17] vircgroup: Introduce virCgroupEnableMissingControllers 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 09 Aug 2018 13:45:42 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 103 ++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 45 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 45fe2595d1..99cbdaa59b 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1494,6 +1494,58 @@ virCgroupNewDetectMachine(const char *name, } =20 =20 +static int +virCgroupEnableMissingControllers(char *path, + pid_t pidleader, + int controllers, + virCgroupPtr *group) +{ + virCgroupPtr parent =3D NULL; + char *offset =3D path; + int ret =3D -1; + + if (virCgroupNew(pidleader, + "", + NULL, + controllers, + &parent) < 0) + return ret; + + for (;;) { + virCgroupPtr tmp; + char *t =3D strchr(offset + 1, '/'); + if (t) + *t =3D '\0'; + + if (virCgroupNew(pidleader, + path, + parent, + controllers, + &tmp) < 0) + goto cleanup; + + if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_NONE) < 0) { + virCgroupFree(&tmp); + goto cleanup; + } + if (t) { + *t =3D '/'; + offset =3D t; + virCgroupFree(&parent); + parent =3D tmp; + } else { + *group =3D tmp; + break; + } + } + + ret =3D 0; + cleanup: + virCgroupFree(&parent); + return ret; +} + + /* * Returns 0 on success, -1 on fatal error, -2 on systemd not available */ @@ -1510,11 +1562,9 @@ virCgroupNewMachineSystemd(const char *name, int controllers, virCgroupPtr *group) { - int ret =3D -1; int rv; - virCgroupPtr init, parent =3D NULL; + virCgroupPtr init; VIR_AUTOFREE(char *) path =3D NULL; - char *offset; =20 VIR_DEBUG("Trying to setup machine '%s' via systemd", name); if ((rv =3D virSystemdCreateMachine(name, @@ -1543,46 +1593,12 @@ virCgroupNewMachineSystemd(const char *name, =20 if (!path || STREQ(path, "/") || path[0] !=3D '/') { VIR_DEBUG("Systemd didn't setup its controller"); - ret =3D -2; - goto cleanup; + return -2; } =20 - offset =3D path; - - if (virCgroupNew(pidleader, - "", - NULL, - controllers, - &parent) < 0) - goto cleanup; - - - for (;;) { - virCgroupPtr tmp; - char *t =3D strchr(offset + 1, '/'); - if (t) - *t =3D '\0'; - - if (virCgroupNew(pidleader, - path, - parent, - controllers, - &tmp) < 0) - goto cleanup; - - if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_NONE) < 0) { - virCgroupFree(&tmp); - goto cleanup; - } - if (t) { - *t =3D '/'; - offset =3D t; - virCgroupFree(&parent); - parent =3D tmp; - } else { - *group =3D tmp; - break; - } + if (virCgroupEnableMissingControllers(path, pidleader, + controllers, group) < 0) { + return -1; } =20 if (virCgroupAddTask(*group, pidleader) < 0) { @@ -1595,10 +1611,7 @@ virCgroupNewMachineSystemd(const char *name, } } =20 - ret =3D 0; - cleanup: - virCgroupFree(&parent); - return ret; + return 0; } =20 =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 16 00:50: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 1533822347580181.40764504077265; Thu, 9 Aug 2018 06:45:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86CE7256A; Thu, 9 Aug 2018 13:45:45 +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 3BBBA7555A; Thu, 9 Aug 2018 13:45:45 +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 C01A624F63; Thu, 9 Aug 2018 13:45:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiP9w015085 for ; Thu, 9 Aug 2018 09:44:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 229332314D; Thu, 9 Aug 2018 13:44:25 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B62672314E for ; Thu, 9 Aug 2018 13:44:24 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:09 +0200 Message-Id: <86cfa395075d5d8f8c69f936e366a0fa6b872549.1533822163.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/17] vircgroup: machinename will never be NULL 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 09 Aug 2018 13:45:46 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit moved machineName generation before virCgroupNewDetectMachine() is called. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 99cbdaa59b..84f5c4197f 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -266,27 +266,22 @@ virCgroupValidateMachineGroup(virCgroupPtr group, if (virCgroupPartitionEscape(&partname) < 0) return false; =20 - if (machinename && - (virAsprintf(&partmachinename, "%s.libvirt-%s", - machinename, drivername) < 0 || - virCgroupPartitionEscape(&partmachinename) < 0)) + if (virAsprintf(&partmachinename, "%s.libvirt-%s", + machinename, drivername) < 0 || + virCgroupPartitionEscape(&partmachinename) < 0) return false; =20 if (!(scopename_old =3D virSystemdMakeScopeName(name, drivername, true= ))) return false; =20 - /* We should keep trying even if this failed */ - if (!machinename) - virResetLastError(); - else if (!(scopename_new =3D virSystemdMakeScopeName(machinename, - drivername, false))) + if (!(scopename_new =3D virSystemdMakeScopeName(machinename, + drivername, false))) return false; =20 if (virCgroupPartitionEscape(&scopename_old) < 0) return false; =20 - if (scopename_new && - virCgroupPartitionEscape(&scopename_new) < 0) + if (virCgroupPartitionEscape(&scopename_new) < 0) return false; =20 for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { @@ -315,16 +310,16 @@ virCgroupValidateMachineGroup(virCgroupPtr group, tmp++; =20 if (STRNEQ(tmp, name) && - STRNEQ_NULLABLE(tmp, machinename) && + STRNEQ(tmp, machinename) && STRNEQ(tmp, partname) && - STRNEQ_NULLABLE(tmp, partmachinename) && + STRNEQ(tmp, partmachinename) && STRNEQ(tmp, scopename_old) && - STRNEQ_NULLABLE(tmp, scopename_new)) { + STRNEQ(tmp, scopename_new)) { VIR_DEBUG("Name '%s' for controller '%s' does not match " "'%s', '%s', '%s', '%s' or '%s'", tmp, virCgroupControllerTypeToString(i), - name, NULLSTR(machinename), partname, - scopename_old, NULLSTR(scopename_new)); + name, machinename, partname, + scopename_old, scopename_new); return false; } } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822352031749.5624092916075; Thu, 9 Aug 2018 06:45:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2C127F3FC; Thu, 9 Aug 2018 13:45:49 +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 A9D332015665; Thu, 9 Aug 2018 13:45:49 +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 5989A1841C66; Thu, 9 Aug 2018 13:45:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiP99015100 for ; Thu, 9 Aug 2018 09:44:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2F8F2314D; Thu, 9 Aug 2018 13:44:25 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 612CE23151 for ; Thu, 9 Aug 2018 13:44:25 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:10 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/17] vircgroup: Remove virCgroupAddTaskController 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 09 Aug 2018 13:45:50 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no need for this function, both of the checks are done later by virCgroupGetControllerPath. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 84f5c4197f..37982a9607 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1128,35 +1128,6 @@ virCgroupNew(pid_t pid, } =20 =20 -/** - * virCgroupAddTaskController: - * - * @group: The cgroup to add a task to - * @pid: The pid of the task to add - * @controller: The cgroup controller to be operated on - * - * Returns: 0 on success or -1 on error - */ -static int -virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller) -{ - if (controller < 0 || controller >=3D VIR_CGROUP_CONTROLLER_LAST) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Controller %d out of range"), controller); - return -1; - } - - if (!group->controllers[controller].mountPoint) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Controller '%s' not mounted"), - virCgroupControllerTypeToString(controller)); - return -1; - } - - return virCgroupSetValueI64(group, controller, "tasks", pid); -} - - static int virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd) { @@ -1174,7 +1145,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pi= d, bool withSystemd) if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD && !withSystemd) continue; =20 - if (virCgroupAddTaskController(group, pid, i) < 0) + if (virCgroupSetValueI64(group, i, "tasks", pid) < 0) goto cleanup; } =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 16 00:50: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 15338222908581.3571853122042512; Thu, 9 Aug 2018 06:44:50 -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 D259D81F07; Thu, 9 Aug 2018 13:44:48 +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 07117182D0; Thu, 9 Aug 2018 13:44:48 +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 21D3E1841C69; Thu, 9 Aug 2018 13:44:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiQwG015110 for ; Thu, 9 Aug 2018 09:44:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F76E2314D; Thu, 9 Aug 2018 13:44:26 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F0242314E for ; Thu, 9 Aug 2018 13:44:25 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:11 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/17] vircgroup: Introduce virCgroupGetMemoryStat 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.25]); Thu, 09 Aug 2018 13:44:49 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 + src/util/vircgroup.c | 88 ++++++++++++++++++++++++++++++++++++++++ src/util/vircgroup.h | 7 ++++ 3 files changed, 96 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 59d9bc380e..ee0dca6129 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1532,6 +1532,7 @@ virCgroupGetDomainTotalCpuStats; virCgroupGetFreezerState; virCgroupGetMemoryHardLimit; virCgroupGetMemorySoftLimit; +virCgroupGetMemoryStat; virCgroupGetMemoryUsage; virCgroupGetMemSwapHardLimit; virCgroupGetMemSwapUsage; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 37982a9607..b91acd13c7 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2427,6 +2427,94 @@ virCgroupSetMemory(virCgroupPtr group, unsigned long= long kb) } =20 =20 +/** + * virCgroupGetMemoryStat: + * + * @group: The cgroup to change memory for + * @cache: page cache memory in KiB + * @activeAnon: anonymous and swap cache memory in KiB + * @inactiveAnon: anonymous and swap cache memory in KiB + * @activeFile: file-backed memory in KiB + * @inactiveFile: file-backed memory in KiB + * @unevictable: memory that cannot be reclaimed KiB + * + * Returns: 0 on success, -1 on error + */ +int +virCgroupGetMemoryStat(virCgroupPtr group, + unsigned long long *cache, + unsigned long long *activeAnon, + unsigned long long *inactiveAnon, + unsigned long long *activeFile, + unsigned long long *inactiveFile, + unsigned long long *unevictable) +{ + int ret =3D -1; + char *stat =3D NULL; + char *line =3D NULL; + unsigned long long cacheVal =3D 0; + unsigned long long activeAnonVal =3D 0; + unsigned long long inactiveAnonVal =3D 0; + unsigned long long activeFileVal =3D 0; + unsigned long long inactiveFileVal =3D 0; + unsigned long long unevictableVal =3D 0; + + if (virCgroupGetValueStr(group, + VIR_CGROUP_CONTROLLER_MEMORY, + "memory.stat", + &stat) < 0) { + return -1; + } + + line =3D stat; + + while (line) { + char *newLine =3D strchr(line, '\n'); + char *valueStr =3D strchr(line, ' '); + unsigned long long value; + + if (newLine) + *newLine =3D '\0'; + + if (!valueStr) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot parse 'memory.stat' cgroup file.")); + goto cleanup; + } + *valueStr =3D '\0'; + + if (virStrToLong_ull(valueStr + 1, NULL, 10, &value) < 0) + goto cleanup; + + if (STREQ(line, "cache")) + cacheVal =3D value >> 10; + else if (STREQ(line, "active_anon")) + activeAnonVal =3D value >> 10; + else if (STREQ(line, "inactive_anon")) + inactiveAnonVal =3D value >> 10; + else if (STREQ(line, "active_file")) + activeFileVal =3D value >> 10; + else if (STREQ(line, "inactive_file")) + inactiveFileVal =3D value >> 10; + else if (STREQ(line, "unevictable")) + unevictableVal =3D value >> 10; + } + + *cache =3D cacheVal; + *activeAnon =3D activeAnonVal; + *inactiveAnon =3D inactiveAnonVal; + *activeFile =3D activeFileVal; + *inactiveFile =3D inactiveFileVal; + *unevictable =3D unevictableVal; + + ret =3D 0; + + cleanup: + VIR_FREE(stat); + return ret; +} + + /** * virCgroupGetMemoryUsage: * diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 48be077aba..c7fdaaede4 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -177,6 +177,13 @@ int virCgroupGetBlkioDeviceWriteBps(virCgroupPtr group, unsigned long long *wbps); =20 int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb); +int virCgroupGetMemoryStat(virCgroupPtr group, + unsigned long long *cache, + unsigned long long *activeAnon, + unsigned long long *inactiveAnon, + unsigned long long *activeFile, + unsigned long long *inactiveFile, + unsigned long long *unevictable); int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb); =20 int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long long kb); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 16 00:50: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 1533822291946957.8603053891378; Thu, 9 Aug 2018 06:44:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A3253082265; Thu, 9 Aug 2018 13:44:50 +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 DA8832015ACA; Thu, 9 Aug 2018 13:44:49 +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 81A4D3F67F; Thu, 9 Aug 2018 13:44:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiRjt015122 for ; Thu, 9 Aug 2018 09:44:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A5452314D; Thu, 9 Aug 2018 13:44:27 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADF192314E for ; Thu, 9 Aug 2018 13:44:26 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:12 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/17] lxc: Use virCgroupGetMemoryStat 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 09 Aug 2018 13:44:50 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/lxc/lxc_cgroup.c | 65 +++++--------------------------------------- 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 8e937ec389..d93a19d684 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -220,64 +220,13 @@ static int virLXCCgroupGetMemTotal(virCgroupPtr cgrou= p, static int virLXCCgroupGetMemStat(virCgroupPtr cgroup, virLXCMeminfoPtr meminfo) { - int ret =3D 0; - FILE *statfd =3D NULL; - char *statFile =3D NULL; - char *line =3D NULL; - size_t n; - - ret =3D virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_MEMORY, - "memory.stat", &statFile); - if (ret !=3D 0) { - virReportSystemError(-ret, "%s", - _("cannot get the path of MEMORY cgroup contr= oller")); - return ret; - } - - statfd =3D fopen(statFile, "r"); - if (statfd =3D=3D NULL) { - ret =3D -errno; - goto cleanup; - } - - while (getline(&line, &n, statfd) > 0) { - - char *value =3D strchr(line, ' '); - char *nl =3D value ? strchr(line, '\n') : NULL; - unsigned long long stat_value; - - if (!value) - continue; - - if (nl) - *nl =3D '\0'; - - *value =3D '\0'; - - if (virStrToLong_ull(value + 1, NULL, 10, &stat_value) < 0) { - ret =3D -EINVAL; - goto cleanup; - } - if (STREQ(line, "cache")) - meminfo->cached =3D stat_value >> 10; - else if (STREQ(line, "inactive_anon")) - meminfo->inactive_anon =3D stat_value >> 10; - else if (STREQ(line, "active_anon")) - meminfo->active_anon =3D stat_value >> 10; - else if (STREQ(line, "inactive_file")) - meminfo->inactive_file =3D stat_value >> 10; - else if (STREQ(line, "active_file")) - meminfo->active_file =3D stat_value >> 10; - else if (STREQ(line, "unevictable")) - meminfo->unevictable =3D stat_value >> 10; - } - ret =3D 0; - - cleanup: - VIR_FREE(line); - VIR_FREE(statFile); - VIR_FORCE_FCLOSE(statfd); - return ret; + return virCgroupGetMemoryStat(cgroup, + &meminfo->cached, + &meminfo->inactive_anon, + &meminfo->active_anon, + &meminfo->inactive_file, + &meminfo->active_file, + &meminfo->unevictable); } =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list