提交 97814d8a 编写于 作者: J Ján Tomko

Show the real cpu shares value in live XML

Currently, the Linux kernel treats values of '0' and '1' as
the minimum of 2. Values larger than the maximum are changed
to the maximum.

Re-reading the shares value after setting it reflects this in
the live domain XML.
上级 bdffab0d
...@@ -38,9 +38,16 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def, ...@@ -38,9 +38,16 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
virCgroupPtr cgroup) virCgroupPtr cgroup)
{ {
int ret = -1; int ret = -1;
if (def->cputune.sharesSpecified &&
virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0) if (def->cputune.sharesSpecified) {
goto cleanup; 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 && if (def->cputune.quota != 0 &&
virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota) < 0) virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota) < 0)
......
...@@ -1898,10 +1898,14 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, ...@@ -1898,10 +1898,14 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) { if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
unsigned long long val;
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0) if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
goto cleanup; goto cleanup;
vm->def->cputune.shares = params[i].value.ul; if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
goto cleanup;
vm->def->cputune.shares = val;
vm->def->cputune.sharesSpecified = true; vm->def->cputune.sharesSpecified = true;
} }
......
...@@ -655,9 +655,15 @@ qemuSetupCpuCgroup(virDomainObjPtr vm) ...@@ -655,9 +655,15 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
} }
} }
if (vm->def->cputune.sharesSpecified && if (vm->def->cputune.sharesSpecified) {
virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0) unsigned long long val;
return -1; if (virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
return -1;
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
return -1;
vm->def->cputune.shares = val;
}
return 0; return 0;
} }
......
...@@ -9085,9 +9085,14 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom, ...@@ -9085,9 +9085,14 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) { if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
unsigned long long val;
if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0) if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
goto cleanup; goto cleanup;
vm->def->cputune.shares = value_ul;
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
goto cleanup;
vm->def->cputune.shares = val;
vm->def->cputune.sharesSpecified = true; vm->def->cputune.sharesSpecified = true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册