if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
goto cleanup;
+ /* Move the thread to the sub dir before changing the settings so that
+ * all take effect even with cgroupv2. */
+ VIR_INFO("Adding pid %d to cgroup", pid);
+ if (virCgroupAddThread(cgroup, pid) < 0)
+ goto cleanup;
+
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (use_cpumask &&
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
goto cleanup;
-
- /* Move the thread to the sub dir */
- VIR_INFO("Adding pid %d to cgroup", pid);
- if (virCgroupAddThread(cgroup, pid) < 0)
- goto cleanup;
-
}
if (!affinity_cpumask)
if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
goto cleanup;
+ /* Move the thread to the sub dir before changing the settings so that
+ * all take effect even with cgroupv2. */
+ if (virCgroupAddThread(cgroup, pid) < 0)
+ goto cleanup;
+
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (use_cpumask &&
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
goto cleanup;
-
- /* Move the thread to the sub dir */
- if (virCgroupAddThread(cgroup, pid) < 0)
- goto cleanup;
-
}
if (!affinity_cpumask)