[PATCH 4/5] Add 'controllers' arg to virCgroupNewDetect

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

 



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

When detecting cgroups we must honour any controllers
whitelist the driver may have.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/lxc/lxc_process.c  | 4 ++--
 src/qemu/qemu_cgroup.c | 1 +
 src/util/vircgroup.c   | 9 ++++++---
 src/util/vircgroup.h   | 2 ++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index e632e13..1a5686f 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1190,7 +1190,7 @@ int virLXCProcessStart(virConnectPtr conn,
     }
 
     if (virCgroupNewDetectMachine(vm->def->name, "lxc",
-                                  vm->pid, &priv->cgroup) < 0)
+                                  vm->pid, -1, &priv->cgroup) < 0)
         goto error;
 
     if (!priv->cgroup) {
@@ -1398,7 +1398,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm,
             goto error;
 
         if (virCgroupNewDetectMachine(vm->def->name, "lxc",
-                                      vm->pid, &priv->cgroup) < 0)
+                                      vm->pid, -1, &priv->cgroup) < 0)
             goto error;
 
         if (!priv->cgroup) {
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 07e901c..9f6b251 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -707,6 +707,7 @@ qemuConnectCgroup(virQEMUDriverPtr driver,
     if (virCgroupNewDetectMachine(vm->def->name,
                                   "qemu",
                                   vm->pid,
+                                  cfg->cgroupControllers,
                                   &priv->cgroup) < 0)
         goto cleanup;
 
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 9065675..3818172 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1406,7 +1406,7 @@ int virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
 */
 int virCgroupNewSelf(virCgroupPtr *group)
 {
-    return virCgroupNewDetect(-1, group);
+    return virCgroupNewDetect(-1, -1, group);
 }
 
 
@@ -1577,12 +1577,14 @@ int virCgroupNewEmulator(virCgroupPtr domain ATTRIBUTE_UNUSED,
 
 #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
 int virCgroupNewDetect(pid_t pid,
+                       int controllers,
                        virCgroupPtr *group)
 {
-    return virCgroupNew(pid, "", NULL, -1, group);
+    return virCgroupNew(pid, "", NULL, controllers, group);
 }
 #else
 int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
+                       int controllers ATTRIBUTE_UNUSED,
                        virCgroupPtr *group ATTRIBUTE_UNUSED)
 {
     virReportSystemError(ENXIO, "%s",
@@ -1597,9 +1599,10 @@ int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
 int virCgroupNewDetectMachine(const char *name,
                               const char *drivername,
                               pid_t pid,
+                              int controllers,
                               virCgroupPtr *group)
 {
-    if (virCgroupNewDetect(pid, group) < 0) {
+    if (virCgroupNewDetect(pid, controllers, group) < 0) {
         if (virCgroupNewIgnoreError())
             return 0;
         return -1;
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index d6222d7..3aaf081 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -76,11 +76,13 @@ int virCgroupNewEmulator(virCgroupPtr domain,
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
 
 int virCgroupNewDetect(pid_t pid,
+                       int controllers,
                        virCgroupPtr *group);
 
 int virCgroupNewDetectMachine(const char *name,
                               const char *drivername,
                               pid_t pid,
+                              int controllers,
                               virCgroupPtr *group);
 
 int virCgroupNewMachine(const char *name,
-- 
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]