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

[libvirt] [PATCH v1 rebase 5/6] create cgroup controllers for emulator according to config



Add a parameter to virCgroupForEmulator to indicate which
cgroup controllers to create. The value of the parameter
is read from user config.
---
 src/qemu/qemu_cgroup.c |  2 +-
 src/qemu/qemu_driver.c |  9 ++++++---
 src/util/cgroup.c      | 12 +++++++++---
 src/util/cgroup.h      |  3 ++-
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 5a1bf7e..5738e93 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -670,7 +670,7 @@ int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 1);
+    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 1, driver->cgroupControllers);
     if (rc < 0) {
         virReportSystemError(-rc,
                              _("Unable to create emulator cgroup for %s"),
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 005dc8a..a6034c2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4418,7 +4418,8 @@ qemuDomainPinEmulator(virDomainPtr dom,
                  */
                 if (virCgroupForDomain(driver->cgroup, vm->def->name,
                                        &cgroup_dom, 0, driver->cgroupControllers) == 0) {
-                    if (virCgroupForEmulator(cgroup_dom, &cgroup_emulator, 0) == 0) {
+                    if (virCgroupForEmulator(cgroup_dom, &cgroup_emulator, 0,
+                                             driver->cgroupControllers) == 0) {
                         if (qemuSetupCgroupEmulatorPin(cgroup_emulator,
                                                        newVcpuPin[0]->cpumask) < 0) {
                             virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -8047,7 +8048,8 @@ qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
         return 0;
     }
 
-    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0);
+    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0,
+                              qemu_driver->cgroupControllers);
     if (rc < 0) {
         virReportSystemError(-rc,
                              _("Unable to find emulator cgroup for %s"),
@@ -8339,7 +8341,8 @@ qemuGetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup,
     }
 
     /* get period and quota for emulator */
-    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0);
+    rc = virCgroupForEmulator(cgroup, &cgroup_emulator, 0,
+                              qemu_driver->cgroupControllers);
     if (!cgroup_emulator) {
         virReportSystemError(-rc,
                              _("Unable to find emulator cgroup for %s"),
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 8b117f3..2e5a7e1 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -1117,14 +1117,19 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
 #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
 int virCgroupForEmulator(virCgroupPtr driver,
                          virCgroupPtr *group,
-                         bool create)
+                         bool create,
+                         int controllers)
 {
+    unsigned flags = VIR_CGROUP_VCPU;
     int rc;
     char *path;
 
     if (driver == NULL)
         return -EINVAL;
 
+    if (!(controllers & (1UL << VIR_CGROUP_CONTROLLER_CPUSET)))
+        flags |= VIR_CGROUP_DISABLE_CPUSET;
+
     if (virAsprintf(&path, "%s/emulator", driver->path) < 0)
         return -ENOMEM;
 
@@ -1132,7 +1137,7 @@ int virCgroupForEmulator(virCgroupPtr driver,
     VIR_FREE(path);
 
     if (rc == 0) {
-        rc = virCgroupMakeGroup(driver, *group, create, VIR_CGROUP_VCPU);
+        rc = virCgroupMakeGroup(driver, *group, create, flags);
         if (rc != 0)
             virCgroupFree(group);
     }
@@ -1142,7 +1147,8 @@ int virCgroupForEmulator(virCgroupPtr driver,
 #else
 int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
                          virCgroupPtr *group ATTRIBUTE_UNUSED,
-                         bool create ATTRIBUTE_UNUSED)
+                         bool create ATTRIBUTE_UNUSED,
+                         int controllers ATTRIBUTE_UNUSED)
 {
     return -ENXIO;
 }
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 4b5cc5c..0ffdd84 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -64,7 +64,8 @@ int virCgroupForVcpu(virCgroupPtr driver,
 
 int virCgroupForEmulator(virCgroupPtr driver,
                          virCgroupPtr *group,
-                         bool create);
+                         bool create,
+                         int controllers);
 
 int virCgroupPathOfController(virCgroupPtr group,
                               int controller,
-- 
1.8.0.1.240.ge8a1f5a


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