From nobody Sun Feb 8 20:53:50 2026 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 1537285599398928.0832317508787; Tue, 18 Sep 2018 08:46:39 -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 BD6E065995; Tue, 18 Sep 2018 15:46: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 74BDF30912F4; Tue, 18 Sep 2018 15:46: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 1A96D4A460; Tue, 18 Sep 2018 15:46:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8IFkIYU011939 for ; Tue, 18 Sep 2018 11:46:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2479C5D9C7; Tue, 18 Sep 2018 15:46:18 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D6ED82213 for ; Tue, 18 Sep 2018 15:46:17 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 18 Sep 2018 17:45:27 +0200 Message-Id: <34957737d3d68f59b372e72b5c3aae5f2af23023.1537285203.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/47] vircgroup: extract virCgroupV1CopyMounts 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.38]); Tue, 18 Sep 2018 15:46: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 Reviewed-by: Fabiano Fid=C3=AAncio Reviewed-by: J=EF=BF=BDn Tomko --- src/util/vircgroup.c | 23 +---------------------- src/util/vircgroupbackend.h | 5 +++++ src/util/vircgroupv1.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 9d6eebc2b9..f5b2a14df9 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -237,27 +237,6 @@ virCgroupPartitionEscape(char **path) } =20 =20 -static int -virCgroupCopyMounts(virCgroupPtr group, - virCgroupPtr parent) -{ - size_t i; - for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { - if (!parent->controllers[i].mountPoint) - continue; - - if (VIR_STRDUP(group->controllers[i].mountPoint, - parent->controllers[i].mountPoint) < 0) - return -1; - - if (VIR_STRDUP(group->controllers[i].linkPoint, - parent->controllers[i].linkPoint) < 0) - return -1; - } - return 0; -} - - static int virCgroupResolveMountLink(const char *mntDir, const char *typeStr, @@ -655,7 +634,7 @@ virCgroupDetect(virCgroupPtr group, } =20 if (parent) { - if (virCgroupCopyMounts(group, parent) < 0) + if (group->backend->copyMounts(group, parent) < 0) return -1; } else { if (virCgroupDetectMounts(group) < 0) diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index daf47bac09..81ee597fc8 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -41,12 +41,17 @@ typedef bool const char *drivername, const char *machinename); =20 +typedef int +(*virCgroupCopyMountsCB)(virCgroupPtr group, + virCgroupPtr parent); + struct _virCgroupBackend { virCgroupBackendType type; =20 /* Mandatory callbacks that need to be implemented for every backend. = */ virCgroupAvailableCB available; virCgroupValidateMachineGroupCB validateMachineGroup; + virCgroupCopyMountsCB copyMounts; }; typedef struct _virCgroupBackend virCgroupBackend; typedef virCgroupBackend *virCgroupBackendPtr; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 48e3d412ae..00c3349aee 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -159,11 +159,33 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group, } =20 =20 +static int +virCgroupV1CopyMounts(virCgroupPtr group, + virCgroupPtr parent) +{ + size_t i; + for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { + if (!parent->controllers[i].mountPoint) + continue; + + if (VIR_STRDUP(group->controllers[i].mountPoint, + parent->controllers[i].mountPoint) < 0) + return -1; + + if (VIR_STRDUP(group->controllers[i].linkPoint, + parent->controllers[i].linkPoint) < 0) + return -1; + } + return 0; +} + + virCgroupBackend virCgroupV1Backend =3D { .type =3D VIR_CGROUP_BACKEND_TYPE_V1, =20 .available =3D virCgroupV1Available, .validateMachineGroup =3D virCgroupV1ValidateMachineGroup, + .copyMounts =3D virCgroupV1CopyMounts, }; =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list