You need to sign in or sign up before continuing.
提交 b3038773 编写于 作者: P Peter Krempa

qemu: Remove virDomainLiveConfigHelperMethod from qemuDomainSetMemoryParameters

上级 62a73bf6
...@@ -9497,6 +9497,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9497,6 +9497,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
unsigned int flags) unsigned int flags)
{ {
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
unsigned long long swap_hard_limit; unsigned long long swap_hard_limit;
...@@ -9508,7 +9509,6 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9508,7 +9509,6 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
int rc; int rc;
int ret = -1; int ret = -1;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
...@@ -9540,23 +9540,18 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9540,23 +9540,18 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
goto cleanup; goto cleanup;
} }
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) if (qemuDomainObjBeginJob(driver, vm, QEMU_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_MEMORY)) { !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID, "%s",
"%s", _("cgroup memory controller is not mounted")); _("cgroup memory controller is not mounted"));
goto endjob; goto endjob;
} }
}
#define VIR_GET_LIMIT_PARAMETER(PARAM, VALUE) \ #define VIR_GET_LIMIT_PARAMETER(PARAM, VALUE) \
if ((rc = virTypedParamsGetULLong(params, nparams, PARAM, &VALUE)) < 0) \ if ((rc = virTypedParamsGetULLong(params, nparams, PARAM, &VALUE)) < 0) \
...@@ -9592,13 +9587,13 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9592,13 +9587,13 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
#define QEMU_SET_MEM_PARAMETER(FUNC, VALUE) \ #define QEMU_SET_MEM_PARAMETER(FUNC, VALUE) \
if (set_ ## VALUE) { \ if (set_ ## VALUE) { \
if (flags & VIR_DOMAIN_AFFECT_LIVE) { \ if (def) { \
if ((rc = FUNC(priv->cgroup, VALUE)) < 0) \ if ((rc = FUNC(priv->cgroup, VALUE)) < 0) \
goto endjob; \ goto endjob; \
vm->def->mem.VALUE = VALUE; \ def->mem.VALUE = VALUE; \
} \ } \
\ \
if (flags & VIR_DOMAIN_AFFECT_CONFIG) \ if (persistentDef) \
persistentDef->mem.VALUE = VALUE; \ persistentDef->mem.VALUE = VALUE; \
} }
...@@ -9606,7 +9601,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9606,7 +9601,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
QEMU_SET_MEM_PARAMETER(virCgroupSetMemorySoftLimit, soft_limit); QEMU_SET_MEM_PARAMETER(virCgroupSetMemorySoftLimit, soft_limit);
/* set hard limit before swap hard limit if decreasing it */ /* set hard limit before swap hard limit if decreasing it */
if (vm->def->mem.hard_limit > hard_limit) { if (def && def->mem.hard_limit > hard_limit) {
QEMU_SET_MEM_PARAMETER(virCgroupSetMemoryHardLimit, hard_limit); QEMU_SET_MEM_PARAMETER(virCgroupSetMemoryHardLimit, hard_limit);
/* inhibit changing the limit a second time */ /* inhibit changing the limit a second time */
set_hard_limit = false; set_hard_limit = false;
...@@ -9619,11 +9614,11 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9619,11 +9614,11 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
#undef QEMU_SET_MEM_PARAMETER #undef QEMU_SET_MEM_PARAMETER
if (flags & VIR_DOMAIN_AFFECT_LIVE && if (def &&
virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto endjob; goto endjob;
if (flags & VIR_DOMAIN_AFFECT_CONFIG && if (persistentDef &&
virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0) virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
goto endjob; goto endjob;
...@@ -9634,7 +9629,6 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ...@@ -9634,7 +9629,6 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
cleanup: cleanup:
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virObjectUnref(cfg); virObjectUnref(cfg);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册