提交 dd1058fa 编写于 作者: J Jim Meyering 提交者: Eric Blake

lxcSetSchedulerParameters: reverse order of tests; diagnose a failure

* src/lxc/lxc_driver.c (lxcSetSchedulerParameters): Ensure that
"->field" is "cpu_shares" before possibly giving a diagnostic about
a type for a "cpu_shares" value.
Also, virCgroupSetCpuShares could fail without evoking a diagnostic.
Add one.
上级 fff6be0c
...@@ -2054,18 +2054,23 @@ static int lxcSetSchedulerParameters(virDomainPtr domain, ...@@ -2054,18 +2054,23 @@ static int lxcSetSchedulerParameters(virDomainPtr domain,
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
virSchedParameterPtr param = &params[i]; virSchedParameterPtr param = &params[i];
if (STRNEQ(param->field, "cpu_shares")) {
lxcError(VIR_ERR_INVALID_ARG,
_("Invalid parameter `%s'"), param->field);
goto cleanup;
}
if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) { if (param->type != VIR_DOMAIN_SCHED_FIELD_ULLONG) {
lxcError(VIR_ERR_INVALID_ARG, "%s", lxcError(VIR_ERR_INVALID_ARG, "%s",
_("Invalid type for cpu_shares tunable, expected a 'ullong'")); _("Invalid type for cpu_shares tunable, expected a 'ullong'"));
goto cleanup; goto cleanup;
} }
if (STREQ(param->field, "cpu_shares")) { int rc = virCgroupSetCpuShares(group, params[i].value.ul);
if (virCgroupSetCpuShares(group, params[i].value.ul) != 0) if (rc != 0) {
goto cleanup; virReportSystemError(-rc, _("failed to set cpu_shares=%llu"),
} else { params[i].value.ul);
lxcError(VIR_ERR_INVALID_ARG,
_("Invalid parameter `%s'"), param->field);
goto cleanup; goto cleanup;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册