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

Use virDomainObjGetDefs in lxcDomainGetMemoryParameters

Instead of virDomainLiveConfigHelperMethod.
上级 c6439104
...@@ -941,11 +941,10 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -941,11 +941,10 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
int *nparams, int *nparams,
unsigned int flags) unsigned int flags)
{ {
virCapsPtr caps = NULL;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainDefPtr def = NULL;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virLXCDomainObjPrivatePtr priv = NULL; virLXCDomainObjPrivatePtr priv = NULL;
virLXCDriverPtr driver = dom->conn->privateData;
unsigned long long val; unsigned long long val;
int ret = -1; int ret = -1;
size_t i; size_t i;
...@@ -962,13 +961,13 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -962,13 +961,13 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
priv = vm->privateData; priv = vm->privateData;
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0 || if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0)
!(caps = virLXCDriverGetCapabilities(driver, false)) ||
virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &persistentDef) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_LIVE && if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto cleanup;
if (def &&
!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) { !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cgroup memory controller is not mounted")); "%s", _("cgroup memory controller is not mounted"));
...@@ -988,7 +987,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -988,7 +987,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 (persistentDef) {
val = persistentDef->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;
...@@ -998,7 +997,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -998,7 +997,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
break; break;
case 1: /* fill memory soft limit here */ case 1: /* fill memory soft limit here */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (persistentDef) {
val = persistentDef->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;
...@@ -1008,7 +1007,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -1008,7 +1007,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
break; break;
case 2: /* fill swap hard limit here */ case 2: /* fill swap hard limit here */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (persistentDef) {
val = persistentDef->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;
...@@ -1027,7 +1026,6 @@ lxcDomainGetMemoryParameters(virDomainPtr dom, ...@@ -1027,7 +1026,6 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
cleanup: cleanup:
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册