Re: [PATCH 06/47] vircgroup: extract virCgroupV1CopyMounts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
 
---
 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)
 }


-static int
-virCgroupCopyMounts(virCgroupPtr group,
-                    virCgroupPtr parent)
-{
-    size_t i;
-    for (i = 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,
     }

     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);

+typedef int
+(*virCgroupCopyMountsCB)(virCgroupPtr group,
+                         virCgroupPtr parent);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;

     /* 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,
 }


+static int
+virCgroupV1CopyMounts(virCgroupPtr group,
+                      virCgroupPtr parent)
+{
+    size_t i;
+    for (i = 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 = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,

     .available = virCgroupV1Available,
     .validateMachineGroup = virCgroupV1ValidateMachineGroup,
+    .copyMounts = virCgroupV1CopyMounts,
 };
 

--
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux