render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c480ed
From ac37b7c9693d27c9c20f87b3fd077bf55ac1d34f Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <ac37b7c9693d27c9c20f87b3fd077bf55ac1d34f@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:06:26 +0200
c480ed
Subject: [PATCH] vircgroup: extract virCgroupV1CopyMounts
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit 47941ea7f52be44f609a6b6acc8895644039e617)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <b833625dd800eee0c3aac96f120ca27dae81ce89.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroup.c        | 23 +----------------------
c480ed
 src/util/vircgroupbackend.h |  5 +++++
c480ed
 src/util/vircgroupv1.c      | 22 ++++++++++++++++++++++
c480ed
 3 files changed, 28 insertions(+), 22 deletions(-)
c480ed
c480ed
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c480ed
index 6825623478..9d644d37d1 100644
c480ed
--- a/src/util/vircgroup.c
c480ed
+++ b/src/util/vircgroup.c
c480ed
@@ -235,27 +235,6 @@ virCgroupPartitionEscape(char **path)
c480ed
 }
c480ed
 
c480ed
 
c480ed
-static int
c480ed
-virCgroupCopyMounts(virCgroupPtr group,
c480ed
-                    virCgroupPtr parent)
c480ed
-{
c480ed
-    size_t i;
c480ed
-    for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c480ed
-        if (!parent->controllers[i].mountPoint)
c480ed
-            continue;
c480ed
-
c480ed
-        if (VIR_STRDUP(group->controllers[i].mountPoint,
c480ed
-                       parent->controllers[i].mountPoint) < 0)
c480ed
-            return -1;
c480ed
-
c480ed
-        if (VIR_STRDUP(group->controllers[i].linkPoint,
c480ed
-                       parent->controllers[i].linkPoint) < 0)
c480ed
-            return -1;
c480ed
-    }
c480ed
-    return 0;
c480ed
-}
c480ed
-
c480ed
-
c480ed
 static int
c480ed
 virCgroupResolveMountLink(const char *mntDir,
c480ed
                           const char *typeStr,
c480ed
@@ -653,7 +632,7 @@ virCgroupDetect(virCgroupPtr group,
c480ed
     }
c480ed
 
c480ed
     if (parent) {
c480ed
-        if (virCgroupCopyMounts(group, parent) < 0)
c480ed
+        if (group->backend->copyMounts(group, parent) < 0)
c480ed
             return -1;
c480ed
     } else {
c480ed
         if (virCgroupDetectMounts(group) < 0)
c480ed
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
c480ed
index daf47bac09..81ee597fc8 100644
c480ed
--- a/src/util/vircgroupbackend.h
c480ed
+++ b/src/util/vircgroupbackend.h
c480ed
@@ -41,12 +41,17 @@ typedef bool
c480ed
                                    const char *drivername,
c480ed
                                    const char *machinename);
c480ed
 
c480ed
+typedef int
c480ed
+(*virCgroupCopyMountsCB)(virCgroupPtr group,
c480ed
+                         virCgroupPtr parent);
c480ed
+
c480ed
 struct _virCgroupBackend {
c480ed
     virCgroupBackendType type;
c480ed
 
c480ed
     /* Mandatory callbacks that need to be implemented for every backend. */
c480ed
     virCgroupAvailableCB available;
c480ed
     virCgroupValidateMachineGroupCB validateMachineGroup;
c480ed
+    virCgroupCopyMountsCB copyMounts;
c480ed
 };
c480ed
 typedef struct _virCgroupBackend virCgroupBackend;
c480ed
 typedef virCgroupBackend *virCgroupBackendPtr;
c480ed
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
c480ed
index b78cdcab53..50b58ab413 100644
c480ed
--- a/src/util/vircgroupv1.c
c480ed
+++ b/src/util/vircgroupv1.c
c480ed
@@ -160,11 +160,33 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static int
c480ed
+virCgroupV1CopyMounts(virCgroupPtr group,
c480ed
+                      virCgroupPtr parent)
c480ed
+{
c480ed
+    size_t i;
c480ed
+    for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
c480ed
+        if (!parent->controllers[i].mountPoint)
c480ed
+            continue;
c480ed
+
c480ed
+        if (VIR_STRDUP(group->controllers[i].mountPoint,
c480ed
+                       parent->controllers[i].mountPoint) < 0)
c480ed
+            return -1;
c480ed
+
c480ed
+        if (VIR_STRDUP(group->controllers[i].linkPoint,
c480ed
+                       parent->controllers[i].linkPoint) < 0)
c480ed
+            return -1;
c480ed
+    }
c480ed
+    return 0;
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV1Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
c480ed
 
c480ed
     .available = virCgroupV1Available,
c480ed
     .validateMachineGroup = virCgroupV1ValidateMachineGroup,
c480ed
+    .copyMounts = virCgroupV1CopyMounts,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed