Add a parameter to virCgroupForDriver to indicate which
cgroup controllers to create. The value of the parameter
is read from user config.
---
src/lxc/lxc_cgroup.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_driver.c | 12 ++++++------
src/util/cgroup.c | 12 +++++++++---
src/util/cgroup.h | 3 ++-
5 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index bdfaa54..a5e2e97 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -226,7 +226,7 @@ int virLXCCgroupSetup(virDomainDefPtr def)
virCgroupPtr cgroup = NULL;
int rc = -1;
- rc = virCgroupForDriver("lxc", &driver, 1, 0);
+ rc = virCgroupForDriver("lxc", &driver, 1, 0, ~0);
if (rc != 0) {
/* Skip all if no driver cgroup is configured */
if (rc == -ENXIO || rc == -ENOENT)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 991b593..5401fe7 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1443,7 +1443,7 @@ static int lxcStartup(int privileged)
lxc_driver->log_libvirtd = 0; /* by default log to container logfile */
lxc_driver->have_netns = lxcCheckNetNsSupport();
- rc = virCgroupForDriver("lxc", &lxc_driver->cgroup, privileged, 1);
+ rc = virCgroupForDriver("lxc", &lxc_driver->cgroup, privileged, 1,
~0);
if (rc < 0) {
char buf[1024] ATTRIBUTE_UNUSED;
VIR_DEBUG("Unable to create cgroup for LXC driver: %s",
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7b8eec6..007fea9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -740,17 +740,17 @@ qemudStartup(int privileged) {
VIR_FREE(base);
- rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged,
1);
- if (rc < 0) {
- VIR_INFO("Unable to create cgroup for driver: %s",
- virStrerror(-rc, ebuf, sizeof(ebuf)));
- }
-
if (qemudLoadDriverConfig(qemu_driver, driverConf) < 0) {
goto error;
}
VIR_FREE(driverConf);
+ rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged, 1,
qemu_driver->cgroupControllers);
+ if (rc < 0) {
+ VIR_INFO("Unable to create cgroup for driver: %s",
+ virStrerror(-rc, ebuf, sizeof(ebuf)));
+ }
+
/* Allocate bitmap for remote display port reservations. We cannot
* do this before the config is loaded properly, since the port
* numbers are configurable now */
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 2f64f5d..02fc24a 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -932,11 +932,13 @@ cleanup:
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
int privileged,
- int create)
+ int create,
+ int controllers)
{
int rc;
char *path = NULL;
virCgroupPtr rootgrp = NULL;
+ unsigned flags = VIR_CGROUP_NONE;
rc = virCgroupAppRoot(privileged, &rootgrp, create);
if (rc != 0)
@@ -947,11 +949,14 @@ int virCgroupForDriver(const char *name,
goto out;
}
+ if (!(controllers & (1UL << VIR_CGROUP_CONTROLLER_CPUSET)))
+ flags |= VIR_CGROUP_DISABLE_CPUSET;
+
rc = virCgroupNew(path, group);
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(rootgrp, *group, create, VIR_CGROUP_NONE);
+ rc = virCgroupMakeGroup(rootgrp, *group, create, flags);
if (rc != 0)
virCgroupFree(group);
}
@@ -965,7 +970,8 @@ out:
int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
int privileged ATTRIBUTE_UNUSED,
- int create ATTRIBUTE_UNUSED)
+ int create ATTRIBUTE_UNUSED,
+ int controllers)
{
/* Claim no support */
return -ENXIO;
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 38fa4b7..f0945f1 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -45,7 +45,8 @@ VIR_ENUM_DECL(virCgroupController);
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
int privileged,
- int create);
+ int create,
+ int controllers);
int virCgroupForDomain(virCgroupPtr driver,
const char *name,
--
1.7.11.7