mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
Use virDomainObjGetDefs in lxcDomainSetBlkioParameters
Remove yet another usage of virDomainLiveConfigHelperMethod along with an sa_assert that helped clang understand the code flow.
This commit is contained in:
parent
a4b1371803
commit
f62e4f2091
@ -2571,10 +2571,10 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
virLXCDriverPtr driver = dom->conn->privateData;
|
virLXCDriverPtr driver = dom->conn->privateData;
|
||||||
size_t i;
|
size_t i;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
|
virDomainDefPtr def = NULL;
|
||||||
virDomainDefPtr persistentDef = NULL;
|
virDomainDefPtr persistentDef = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virLXCDriverConfigPtr cfg = NULL;
|
virLXCDriverConfigPtr cfg = NULL;
|
||||||
virCapsPtr caps = NULL;
|
|
||||||
virLXCDomainObjPrivatePtr priv;
|
virLXCDomainObjPrivatePtr priv;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
@ -2604,17 +2604,13 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
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, vm, &flags,
|
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
|
||||||
&persistentDef) < 0)
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (def) {
|
||||||
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
|
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("blkio cgroup isn't mounted"));
|
_("blkio cgroup isn't mounted"));
|
||||||
@ -2623,7 +2619,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (def) {
|
||||||
for (i = 0; i < nparams; i++) {
|
for (i = 0; i < nparams; i++) {
|
||||||
virTypedParameterPtr param = ¶ms[i];
|
virTypedParameterPtr param = ¶ms[i];
|
||||||
|
|
||||||
@ -2718,8 +2714,8 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (j != ndevices ||
|
if (j != ndevices ||
|
||||||
lxcDomainMergeBlkioDevice(&vm->def->blkio.devices,
|
lxcDomainMergeBlkioDevice(&def->blkio.devices,
|
||||||
&vm->def->blkio.ndevices,
|
&def->blkio.ndevices,
|
||||||
devices, ndevices, param->field) < 0)
|
devices, ndevices, param->field) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
virBlkioDeviceArrayClear(devices, ndevices);
|
virBlkioDeviceArrayClear(devices, ndevices);
|
||||||
@ -2729,10 +2725,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
if (persistentDef) {
|
||||||
/* Clang can't see that if we get here, persistentDef was set. */
|
|
||||||
sa_assert(persistentDef);
|
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++) {
|
for (i = 0; i < nparams; i++) {
|
||||||
virTypedParameterPtr param = ¶ms[i];
|
virTypedParameterPtr param = ¶ms[i];
|
||||||
|
|
||||||
@ -2771,7 +2764,6 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
virObjectUnref(caps);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user