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 | 13 +++++++------
src/util/cgroup.c | 12 +++++++++---
src/util/cgroup.h | 3 ++-
5 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 767ef26..0af9dcc 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -371,7 +371,7 @@ int virLXCCgroupSetup(virDomainDefPtr def)
int ret = -1;
int rc;
- rc = virCgroupForDriver("lxc", &driver, 1, 0);
+ rc = virCgroupForDriver("lxc", &driver, 1, 0, ~0);
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("Unable to get cgroup for driver"));
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index e0e76e6..3f5aa80 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1448,7 +1448,7 @@ static int lxcStartup(bool 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 1228f6e..d155ea7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -797,17 +797,18 @@ qemuStartup(bool 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 (qemuLoadDriverConfig(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 e955a22..37a5c08 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -934,11 +934,13 @@ cleanup:
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
bool privileged,
- bool create)
+ bool create,
+ int controllers)
{
int rc;
char *path = NULL;
virCgroupPtr rootgrp = NULL;
+ unsigned flags = VIR_CGROUP_NONE;
rc = virCgroupAppRoot(privileged, &rootgrp, create);
if (rc != 0)
@@ -949,11 +951,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);
}
@@ -967,7 +972,8 @@ out:
int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
bool privileged ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED)
+ bool create ATTRIBUTE_UNUSED,
+ int controllers)
{
/* Claim no support */
return -ENXIO;
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index fc9e409..3e3be91 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,
bool privileged,
- bool create);
+ bool create,
+ int controllers);
int virCgroupGetAppRoot(virCgroupPtr *group);
--
1.8.0.1.240.ge8a1f5a