mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
libxl: Use virDomainLiveConfigHelperMethod for libxlDomainSetMemoryFlags
Flag expansion is the same as in virDomainObjUpdateModificationImpact which virDomainLiveConfigHelperMethod calls internally. The difference is merely in implementation. Note that VIR_DOMAIN_MEM_CONFIG is the same as VIR_DOMAIN_AFFECT_CONFIG. Additionally, the called functions will properly use flag OR and thus handle the VIR_DOMAIN_MEM_MAXIMUM case. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
34111a60f8
commit
4cf22bdcfd
@ -1445,7 +1445,6 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virDomainDefPtr persistentDef = NULL;
|
virDomainDefPtr persistentDef = NULL;
|
||||||
bool isActive;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_MEM_LIVE |
|
virCheckFlags(VIR_DOMAIN_MEM_LIVE |
|
||||||
@ -1461,38 +1460,9 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
isActive = virDomainObjIsActive(vm);
|
if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm, &flags,
|
||||||
|
&persistentDef) < 0)
|
||||||
if (flags == VIR_DOMAIN_MEM_CURRENT) {
|
|
||||||
if (isActive)
|
|
||||||
flags = VIR_DOMAIN_MEM_LIVE;
|
|
||||||
else
|
|
||||||
flags = VIR_DOMAIN_MEM_CONFIG;
|
|
||||||
}
|
|
||||||
if (flags == VIR_DOMAIN_MEM_MAXIMUM) {
|
|
||||||
if (isActive)
|
|
||||||
flags = VIR_DOMAIN_MEM_LIVE | VIR_DOMAIN_MEM_MAXIMUM;
|
|
||||||
else
|
|
||||||
flags = VIR_DOMAIN_MEM_CONFIG | VIR_DOMAIN_MEM_MAXIMUM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isActive && (flags & VIR_DOMAIN_MEM_LIVE)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("cannot set memory on an inactive domain"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_MEM_CONFIG) {
|
|
||||||
if (!vm->persistent) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("cannot change persistent config of a transient domain"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
if (!(persistentDef = virDomainObjGetPersistentDef(cfg->caps,
|
|
||||||
driver->xmlopt,
|
|
||||||
vm)))
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_MEM_MAXIMUM) {
|
if (flags & VIR_DOMAIN_MEM_MAXIMUM) {
|
||||||
/* resize the maximum memory */
|
/* resize the maximum memory */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user