static int virLXCCgroupSetupCpuTune(virDomainDefPtr def, virCgroupPtr cgroup) { int ret = -1; if (def->cputune.sharesSpecified) { unsigned long long val; if (virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0) goto cleanup; if (virCgroupGetCpuShares(cgroup, &val) < 0) goto cleanup; def->cputune.shares = val; } if (def->cputune.quota != 0 && virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota) < 0) goto cleanup; if (def->cputune.period != 0 && virCgroupSetCpuCfsPeriod(cgroup, def->cputune.period) < 0) goto cleanup; ret = 0; cleanup: return ret; }
static int virLXCCgroupSetupCpuTune(virDomainDefPtr def, virCgroupPtr cgroup) { int ret = -1; if (def->cputune.shares != 0) { int rc = virCgroupSetCpuShares(cgroup, def->cputune.shares); if (rc != 0) { virReportSystemError(-rc, _("Unable to set io cpu shares for domain %s"), def->name); goto cleanup; } } if (def->cputune.quota != 0) { int rc = virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota); if (rc != 0) { virReportSystemError(-rc, _("Unable to set io cpu quota for domain %s"), def->name); goto cleanup; } } if (def->cputune.period != 0) { int rc = virCgroupSetCpuCfsPeriod(cgroup, def->cputune.period); if (rc != 0) { virReportSystemError(-rc, _("Unable to set io cpu period for domain %s"), def->name); goto cleanup; } } ret = 0; cleanup: return ret; }
static int virLXCCgroupSetupCpuTune(virDomainDefPtr def, virCgroupPtr cgroup) { int ret = -1; if (def->cputune.shares != 0 && virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0) goto cleanup; if (def->cputune.quota != 0 && virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota) < 0) goto cleanup; if (def->cputune.period != 0 && virCgroupSetCpuCfsPeriod(cgroup, def->cputune.period) < 0) goto cleanup; ret = 0; cleanup: return ret; }
int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup, unsigned long long period, long long quota) { unsigned long long old_period; if (period == 0 && quota == 0) return 0; if (period) { /* get old period, and we can rollback if set quota failed */ if (virCgroupGetCpuCfsPeriod(cgroup, &old_period) < 0) return -1; if (virCgroupSetCpuCfsPeriod(cgroup, period) < 0) return -1; } if (quota && virCgroupSetCpuCfsQuota(cgroup, quota) < 0) goto error; return 0; error: if (period) { virErrorPtr saved = virSaveLastError(); ignore_value(virCgroupSetCpuCfsPeriod(cgroup, old_period)); if (saved) { virSetError(saved); virFreeError(saved); } } return -1; }