[PATCH 09/47] vircgroup: extract virCgroupV1ValidatePlacement

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroup.c        | 32 +-------------------------------
 src/util/vircgroupbackend.h |  5 +++++
 src/util/vircgroupv1.c      | 31 +++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 0fcb047a0c..864dd876b0 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -351,36 +351,6 @@ virCgroupDetectPlacement(virCgroupPtr group,
 }
 
 
-static int
-virCgroupValidatePlacement(virCgroupPtr group,
-                           pid_t pid)
-{
-    size_t i;
-
-    for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
-        if (!group->controllers[i].mountPoint)
-            continue;
-
-        if (!group->controllers[i].placement) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Could not find placement for controller %s at %s"),
-                           virCgroupControllerTypeToString(i),
-                           group->controllers[i].placement);
-            return -1;
-        }
-
-        VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
-                  i,
-                  virCgroupControllerTypeToString(i),
-                  group->controllers[i].mountPoint,
-                  group->controllers[i].placement,
-                  (long long) pid);
-    }
-
-    return 0;
-}
-
-
 static int
 virCgroupDetectControllers(virCgroupPtr group,
                            int controllers)
@@ -506,7 +476,7 @@ virCgroupDetect(virCgroupPtr group,
         return -1;
 
     /* Check that for every mounted controller, we found our placement */
-    if (virCgroupValidatePlacement(group, pid) < 0)
+    if (group->backend->validatePlacement(group, pid) < 0)
         return -1;
 
     return 0;
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 85906e7191..086cfb8090 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -62,6 +62,10 @@ typedef int
                               const char *controllers,
                               const char *selfpath);
 
+typedef int
+(*virCgroupValidatePlacementCB)(virCgroupPtr group,
+                                pid_t pid);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;
 
@@ -72,6 +76,7 @@ struct _virCgroupBackend {
     virCgroupCopyPlacementCB copyPlacement;
     virCgroupDetectMountsCB detectMounts;
     virCgroupDetectPlacementCB detectPlacement;
+    virCgroupValidatePlacementCB validatePlacement;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index f73f40db0e..68df323d72 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -372,6 +372,36 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV1ValidatePlacement(virCgroupPtr group,
+                             pid_t pid)
+{
+    size_t i;
+
+    for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+        if (!group->controllers[i].mountPoint)
+            continue;
+
+        if (!group->controllers[i].placement) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Could not find placement for v1 controller %s at %s"),
+                           virCgroupV1ControllerTypeToString(i),
+                           group->controllers[i].placement);
+            return -1;
+        }
+
+        VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
+                  i,
+                  virCgroupV1ControllerTypeToString(i),
+                  group->controllers[i].mountPoint,
+                  group->controllers[i].placement,
+                  (long long) pid);
+    }
+
+    return 0;
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
 
@@ -381,6 +411,7 @@ virCgroupBackend virCgroupV1Backend = {
     .copyPlacement = virCgroupV1CopyPlacement,
     .detectMounts = virCgroupV1DetectMounts,
     .detectPlacement = virCgroupV1DetectPlacement,
+    .validatePlacement = virCgroupV1ValidatePlacement,
 };
 
 
-- 
2.17.1

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