Add a parameter to virCgroupForVcpu to indicate which
cgroup controllers to create. The value of the parameter
is read from user config.
---
src/qemu/qemu_cgroup.c | 3 ++-
src/qemu/qemu_driver.c | 18 ++++++++++++------
src/util/cgroup.c | 9 +++++++--
src/util/cgroup.h | 3 ++-
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ba54a68..04a2c08 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -576,7 +576,8 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver,
virDomainObjPtr vm)
}
for (i = 0; i < priv->nvcpupids; i++) {
- rc = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 1);
+ rc = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 1,
+ driver->cgroupControllers);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to create vcpu cgroup for %s(vcpu:"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cc532c7..dcaa693 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3716,7 +3716,8 @@ static int qemudDomainHotplugVcpus(struct qemud_driver *driver,
if (cgroup_available) {
int rv = -1;
/* Create cgroup for the onlined vcpu */
- rv = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 1);
+ rv = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 1,
+ driver->cgroupControllers);
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to create vcpu cgroup for
%s(vcpu:"
@@ -3790,7 +3791,8 @@ static int qemudDomainHotplugVcpus(struct qemud_driver *driver,
if (cgroup_available) {
int rv = -1;
- rv = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 0);
+ rv = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 0,
+ driver->cgroupControllers);
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to access vcpu cgroup for
%s(vcpu:"
@@ -4037,7 +4039,8 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (virCgroupForDomain(driver->cgroup, vm->def->name,
&cgroup_dom, 0,
driver->cgroupControllers) == 0 &&
- virCgroupForVcpu(cgroup_dom, vcpu, &cgroup_vcpu, 0) == 0 &&
+ virCgroupForVcpu(cgroup_dom, vcpu, &cgroup_vcpu, 0,
+ driver->cgroupControllers) == 0 &&
qemuSetupCgroupVcpuPin(cgroup_vcpu, newVcpuPin, newVcpuPinNum, vcpu) <
0) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("failed to set cpuset.cpus in cgroup"
@@ -7897,7 +7900,8 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
*/
if (priv->nvcpupids != 0 && priv->vcpupids[0] != vm->pid) {
for (i = 0; i < priv->nvcpupids; i++) {
- rc = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 0);
+ rc = virCgroupForVcpu(cgroup, i, &cgroup_vcpu, 0,
+ qemu_driver->cgroupControllers);
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to find vcpu cgroup for
%s(vcpu:"
@@ -8188,7 +8192,8 @@ qemuGetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
}
/* get period and quota for vcpu0 */
- rc = virCgroupForVcpu(cgroup, 0, &cgroup_vcpu, 0);
+ rc = virCgroupForVcpu(cgroup, 0, &cgroup_vcpu, 0,
+ qemu_driver->cgroupControllers);
if (!cgroup_vcpu) {
virReportSystemError(-rc,
_("Unable to find vcpu cgroup for %s(vcpu: 0)"),
@@ -14110,7 +14115,8 @@ getSumVcpuPercpuStats(virCgroupPtr group,
unsigned long long tmp;
int j;
- if (virCgroupForVcpu(group, i, &group_vcpu, 0) < 0) {
+ if (virCgroupForVcpu(group, i, &group_vcpu, 0,
+ qemu_driver->cgroupControllers) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error accessing cgroup cpuacct for vcpu"));
goto cleanup;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index d07a66a..b43933e 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -1052,14 +1052,19 @@ int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid,
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/vcpu%d", driver->path, vcpuid) < 0)
return -ENOMEM;
@@ -1067,7 +1072,7 @@ int virCgroupForVcpu(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);
}
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index b121bca..dc0811a 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -57,7 +57,8 @@ int virCgroupForDomain(virCgroupPtr driver,
int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid,
virCgroupPtr *group,
- int create);
+ int create,
+ int controllers);
int virCgroupForEmulator(virCgroupPtr driver,
virCgroupPtr *group,
--
1.7.11.7