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

[libvirt] [PATCH v1 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 04a2c08..69320e4 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -670,7 +670,7 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *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 dcaa693..e9985e8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4306,7 +4306,8 @@ qemudDomainPinEmulator(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",
@@ -7939,7 +7940,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"),
@@ -8231,7 +8233,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 b43933e..d069bf5 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -1100,14 +1100,19 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
 #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
 int virCgroupForEmulator(virCgroupPtr driver,
                           virCgroupPtr *group,
-                          int create)
+                          int 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;
 
@@ -1115,7 +1120,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);
     }
@@ -1125,7 +1130,8 @@ int virCgroupForEmulator(virCgroupPtr driver,
 #else
 int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
                           virCgroupPtr *group ATTRIBUTE_UNUSED,
-                          int create ATTRIBUTE_UNUSED)
+                          int create ATTRIBUTE_UNUSED,
+                          int controllers ATTRIBUTE_UNUSED)
 {
     return -ENXIO;
 }
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index dc0811a..e3bdc9b 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -62,7 +62,8 @@ int virCgroupForVcpu(virCgroupPtr driver,
 
 int virCgroupForEmulator(virCgroupPtr driver,
                          virCgroupPtr *group,
-                         int create);
+                         int create,
+                         int controllers);
 
 int virCgroupPathOfController(virCgroupPtr group,
                               int controller,
-- 
1.7.11.7


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