mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
Use virDomainObjGetDefs in lxcDomainSetSchedulerParametersFlags
On LXC domain startup we have already called virDomainObjSetDefTransient to fill vm->newDef. There is no need to call virDomainLiveConfigHelperMethod which has the ability to fill newDef if it's NULL.
This commit is contained in:
parent
15654cc594
commit
1ca45c8fb5
@ -1947,6 +1947,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
|
virDomainDefPtr def = NULL;
|
||||||
virDomainDefPtr persistentDefCopy = NULL;
|
virDomainDefPtr persistentDefCopy = NULL;
|
||||||
virDomainDefPtr persistentDef = NULL;
|
virDomainDefPtr persistentDef = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1980,18 +1981,17 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
vm, &flags, &persistentDef) < 0)
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (persistentDef) {
|
||||||
/* Make a copy for updated domain. */
|
/* Make a copy for updated domain. */
|
||||||
persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
|
persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
|
||||||
if (!persistentDefCopy)
|
if (!persistentDefCopy)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (def) {
|
||||||
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
|
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("cgroup CPU controller is not mounted"));
|
"%s", _("cgroup CPU controller is not mounted"));
|
||||||
@ -2003,7 +2003,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
virTypedParameterPtr param = ¶ms[i];
|
virTypedParameterPtr param = ¶ms[i];
|
||||||
|
|
||||||
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 (def) {
|
||||||
unsigned long long val;
|
unsigned long long val;
|
||||||
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
|
if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -2011,37 +2011,37 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
vm->def->cputune.shares = val;
|
def->cputune.shares = val;
|
||||||
vm->def->cputune.sharesSpecified = true;
|
def->cputune.sharesSpecified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (persistentDef) {
|
||||||
persistentDefCopy->cputune.shares = params[i].value.ul;
|
persistentDefCopy->cputune.shares = params[i].value.ul;
|
||||||
persistentDefCopy->cputune.sharesSpecified = true;
|
persistentDefCopy->cputune.sharesSpecified = true;
|
||||||
}
|
}
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
|
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (def) {
|
||||||
rc = lxcSetVcpuBWLive(priv->cgroup, params[i].value.ul, 0);
|
rc = lxcSetVcpuBWLive(priv->cgroup, params[i].value.ul, 0);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (params[i].value.ul)
|
if (params[i].value.ul)
|
||||||
vm->def->cputune.period = params[i].value.ul;
|
def->cputune.period = params[i].value.ul;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (persistentDef)
|
||||||
persistentDefCopy->cputune.period = params[i].value.ul;
|
persistentDefCopy->cputune.period = params[i].value.ul;
|
||||||
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
|
} else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (def) {
|
||||||
rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
|
rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (params[i].value.l)
|
if (params[i].value.l)
|
||||||
vm->def->cputune.quota = params[i].value.l;
|
def->cputune.quota = params[i].value.l;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (persistentDef)
|
||||||
persistentDefCopy->cputune.quota = params[i].value.l;
|
persistentDefCopy->cputune.quota = params[i].value.l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2050,7 +2050,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (persistentDef) {
|
||||||
rc = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDefCopy);
|
rc = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDefCopy);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
Loading…
Reference in New Issue
Block a user