diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index ab21e127097ea3b4aa9f41c54e8f35c985f7f80f..e1a28272ee7b959914835595c6aed79b17394f8d 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1025,10 +1025,6 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm) if (virCgroupAddTask(cgroup_vcpu, priv->vcpupids[i]) < 0) goto cleanup; - if (mem_mask && - virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0) - goto cleanup; - if (period || quota) { if (qemuSetupCgroupVcpuBW(cgroup_vcpu, period, quota) < 0) goto cleanup; @@ -1038,6 +1034,10 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm) if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { virBitmapPtr cpumap = NULL; + if (mem_mask && + virCgroupSetCpusetMems(cgroup_vcpu, mem_mask) < 0) + goto cleanup; + /* try to use the default cpu maps */ if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) cpumap = priv->autoCpuset; @@ -1202,15 +1202,15 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm) goto cleanup; } - if (mem_mask && - virCgroupSetCpusetMems(cgroup_iothread, mem_mask) < 0) - goto cleanup; - /* Set iothreadpin in cgroup if iothreadpin xml is provided */ if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { virBitmapPtr cpumask = NULL; + if (mem_mask && + virCgroupSetCpusetMems(cgroup_iothread, mem_mask) < 0) + goto cleanup; + if (def->iothreadids[i]->cpumask) cpumask = def->iothreadids[i]->cpumask; else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b9278f87acd867028350607f0df2ab2301371263..7a984a86ab3a06e613396f4f59d56779e10a06e8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4597,7 +4597,9 @@ qemuDomainAddCgroupForThread(virCgroupPtr cgroup, if (virCgroupNewThread(cgroup, nameval, idx, true, &new_cgroup) < 0) return NULL; - if (mem_mask && virCgroupSetCpusetMems(new_cgroup, mem_mask) < 0) + if (mem_mask && + virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET) && + virCgroupSetCpusetMems(new_cgroup, mem_mask) < 0) goto error; /* Add pid/thread to the cgroup */ @@ -4653,7 +4655,8 @@ qemuDomainHotplugPinThread(virBitmapPtr cpumask, { int ret = -1; - if (cgroup) { + if (cgroup && + virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (qemuSetupCgroupCpusetCpus(cgroup, cpumask) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, _("failed to set cpuset.cpus in cgroup for id %d"), @@ -4896,7 +4899,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; - if (def && !(flags & VIR_DOMAIN_VCPU_GUEST) && virNumaIsAvailable()) { + if (def && !(flags & VIR_DOMAIN_VCPU_GUEST) && virNumaIsAvailable() && + virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR, 0, false, &cgroup_temp) < 0) goto endjob;