[PATCH 3/5] Fix detection of 'emulator' cgroup

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

When a VM has an 'emulator' child cgroup present, we must
strip off that suffix when detecting the cgroup for a
machine

Rename the virCgroupIsValidMachineGroup method to
virCgroupValidateMachineGroup to make a bit clearer
that this isn't simply a boolean check, it will make
changes to the object.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/util/vircgroup.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 308f1a1..9065675 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -96,9 +96,10 @@ bool virCgroupAvailable(void)
 }
 
 static bool 
-virCgroupIsValidMachineGroup(virCgroupPtr group,
-                             const char *name,
-                             const char *drivername)
+virCgroupValidateMachineGroup(virCgroupPtr group,
+                              const char *name,
+                              const char *drivername,
+                              bool stripEmulatorSuffix)
 {
     size_t i;
     bool valid = false;
@@ -120,12 +121,26 @@ virCgroupIsValidMachineGroup(virCgroupPtr group,
         tmp = strrchr(group->controllers[i].placement, '/');
         if (!tmp)
             goto cleanup;
+
+        if (stripEmulatorSuffix &&
+            (i == VIR_CGROUP_CONTROLLER_CPU ||
+             i == VIR_CGROUP_CONTROLLER_CPUACCT ||
+             i == VIR_CGROUP_CONTROLLER_CPUSET)) {
+            if (STREQ(tmp, "/emulator"))
+                *tmp = '\0';
+            tmp = strrchr(group->controllers[i].placement, '/');
+            if (!tmp)
+                goto cleanup;
+        }
+
         tmp++;
 
         if (STRNEQ(tmp, name) &&
-            STRNEQ(tmp, partname))
+            STRNEQ(tmp, partname)) {
+            VIR_DEBUG("Name '%s' does not match '%s' or '%s'",
+                      tmp, name, partname);
             goto cleanup;
-
+        }
     }
 
     valid = true;
@@ -1590,7 +1605,9 @@ int virCgroupNewDetectMachine(const char *name,
         return -1;
     }
 
-    if (!virCgroupIsValidMachineGroup(*group, name, drivername)) {
+    if (!virCgroupValidateMachineGroup(*group, name, drivername, true)) {
+        VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
+                  name, drivername);
         virCgroupFree(group);
         return 0;
     }
-- 
1.8.1.4

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