lxc: rename vmdef to persistentDef

A few functions using virDomainLiveConfigHelperMethod use the generic
name 'vmdef' to point to the persistent definition.

Use persistentDef and/or persistentDefCopy to make its purpose obvious.
This commit is contained in:
Ján Tomko 2016-05-28 13:45:18 +02:00
parent 8dfb796080
commit c646cd742a

View File

@ -807,7 +807,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
unsigned int flags) unsigned int flags)
{ {
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
virDomainDefPtr vmdef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virLXCDomainObjPrivatePtr priv = NULL; virLXCDomainObjPrivatePtr priv = NULL;
virLXCDriverConfigPtr cfg = NULL; virLXCDriverConfigPtr cfg = NULL;
@ -848,7 +848,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &vmdef) < 0) vm, &flags, &persistentDef) < 0)
goto endjob; goto endjob;
if (flags & VIR_DOMAIN_AFFECT_LIVE && if (flags & VIR_DOMAIN_AFFECT_LIVE &&
@ -904,7 +904,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
} \ } \
\ \
if (flags & VIR_DOMAIN_AFFECT_CONFIG) \ if (flags & VIR_DOMAIN_AFFECT_CONFIG) \
vmdef->mem.VALUE = VALUE; \ persistentDef->mem.VALUE = VALUE; \
} }
/* Soft limit doesn't clash with the others */ /* Soft limit doesn't clash with the others */
@ -925,7 +925,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
#undef LXC_SET_MEM_PARAMETER #undef LXC_SET_MEM_PARAMETER
if (flags & VIR_DOMAIN_AFFECT_CONFIG && if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0) virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
goto endjob; goto endjob;
ret = 0; ret = 0;
@ -947,7 +947,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
unsigned int flags) unsigned int flags)
{ {
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
virDomainDefPtr vmdef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virLXCDomainObjPrivatePtr priv = NULL; virLXCDomainObjPrivatePtr priv = NULL;
virLXCDriverPtr driver = dom->conn->privateData; virLXCDriverPtr driver = dom->conn->privateData;
@ -970,7 +970,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0 || if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0 ||
!(caps = virLXCDriverGetCapabilities(driver, false)) || !(caps = virLXCDriverGetCapabilities(driver, false)) ||
virDomainLiveConfigHelperMethod(caps, driver->xmlopt, virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &vmdef) < 0) vm, &flags, &persistentDef) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_LIVE && if (flags & VIR_DOMAIN_AFFECT_LIVE &&
@ -994,7 +994,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
switch (i) { switch (i) {
case 0: /* fill memory hard limit here */ case 0: /* fill memory hard limit here */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
val = vmdef->mem.hard_limit; val = persistentDef->mem.hard_limit;
} else if (virCgroupGetMemoryHardLimit(priv->cgroup, &val) < 0) { } else if (virCgroupGetMemoryHardLimit(priv->cgroup, &val) < 0) {
goto cleanup; goto cleanup;
} }
@ -1004,7 +1004,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
break; break;
case 1: /* fill memory soft limit here */ case 1: /* fill memory soft limit here */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
val = vmdef->mem.soft_limit; val = persistentDef->mem.soft_limit;
} else if (virCgroupGetMemorySoftLimit(priv->cgroup, &val) < 0) { } else if (virCgroupGetMemorySoftLimit(priv->cgroup, &val) < 0) {
goto cleanup; goto cleanup;
} }
@ -1014,7 +1014,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
break; break;
case 2: /* fill swap hard limit here */ case 2: /* fill swap hard limit here */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
val = vmdef->mem.swap_hard_limit; val = persistentDef->mem.swap_hard_limit;
} else if (virCgroupGetMemSwapHardLimit(priv->cgroup, &val) < 0) { } else if (virCgroupGetMemSwapHardLimit(priv->cgroup, &val) < 0) {
goto cleanup; goto cleanup;
} }
@ -1952,7 +1952,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
size_t i; size_t i;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL; virDomainDefPtr persistentDefCopy = NULL;
virDomainDefPtr persistentDef = NULL;
int ret = -1; int ret = -1;
int rc; int rc;
virLXCDomainObjPrivatePtr priv; virLXCDomainObjPrivatePtr priv;
@ -1985,13 +1986,13 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
goto cleanup; goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &vmdef) < 0) vm, &flags, &persistentDef) < 0)
goto endjob; goto endjob;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
if (!vmdef) if (!persistentDefCopy)
goto endjob; goto endjob;
} }
@ -2020,8 +2021,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vmdef->cputune.shares = params[i].value.ul; persistentDefCopy->cputune.shares = params[i].value.ul;
vmdef->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 (flags & VIR_DOMAIN_AFFECT_LIVE) {
@ -2034,7 +2035,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) if (flags & VIR_DOMAIN_AFFECT_CONFIG)
vmdef->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 (flags & VIR_DOMAIN_AFFECT_LIVE) {
rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l); rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
@ -2046,7 +2047,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) if (flags & VIR_DOMAIN_AFFECT_CONFIG)
vmdef->cputune.quota = params[i].value.l; persistentDefCopy->cputune.quota = params[i].value.l;
} }
} }
@ -2055,12 +2056,12 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
rc = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef); rc = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDefCopy);
if (rc < 0) if (rc < 0)
goto endjob; goto endjob;
virDomainObjAssignDef(vm, vmdef, false, NULL); virDomainObjAssignDef(vm, persistentDefCopy, false, NULL);
vmdef = NULL; persistentDefCopy = NULL;
} }
ret = 0; ret = 0;
@ -2069,7 +2070,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
virLXCDomainObjEndJob(driver, vm); virLXCDomainObjEndJob(driver, vm);
cleanup: cleanup:
virDomainDefFree(vmdef); virDomainDefFree(persistentDefCopy);
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps); virObjectUnref(caps);
virObjectUnref(cfg); virObjectUnref(cfg);